Workflow generator does not rewrite node-id references nested inside lists

オープン 初心者向け
#42,355 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
ai, backend, testing-qa

調査の方向性

api/core/workflow/generator/runner.py の WorkflowGenerator._rewrite_refs_in_data と、その case list() 分岐から始めます。api/tests/unit_tests/core/workflow/generator/test_runner.py にある名前付きの2つの回帰テストを実行し、その後、ネストされたセレクターペアとプレースホルダー文字列が _sanitize_node_ids の後に書き換えられ、UNKNOWN_NODE_REFERENCE が残っていないことを確認します。

索引モデルが issue の本文から書いたものです。

説明

Self Checks
  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.
Dify version

1.17.1 (main, 38f9d85)

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

WorkflowGenerator._sanitize_node_ids renames LLM-emitted node ids that contain
characters rejected by the runtime placeholder regex (hyphens, dots, spaces —
e.g. node-1 -> node1) and rewrites every cross-reference to them: edge
source/target, parentId-style id fields, {{#id.var#}} placeholders, and
["node-id", "var"] selector lists.

The rewrite walker _rewrite_refs_in_data handles the selector shape only when
it is a direct dict value. When a ["node-id", "var"] pair is nested inside
another list — e.g. a variable-aggregator node's data.variables
(list[list[str]]), its advanced_settings.groups[].variables, or an end
node's end_stream_variable_selector_mapping values (dict[str, list[list[str]]]) — the case list() arm only recurses, so the stale id is
left in place. Placeholder-bearing strings inside lists are likewise skipped.

Where: api/core/workflow/generator/runner.py, _rewrite_refs_in_data, case list()
arm (around line 2028).

from core.workflow.generator.runner import WorkflowGenerator

nodes = [
    {"id": "node-1", "data": {"type": "llm", "title": "A"}},
    {"id": "node-2", "data": {"type": "llm", "title": "B"}},
    {"id": "join", "data": {
        "type": "variable-aggregator",
        "variables": [["node-1", "text"], ["node-2", "text"]],
    }},
]
WorkflowGenerator._sanitize_node_ids(nodes=nodes, edges=[])
assert nodes[2]["data"]["variables"] == [["node1", "text"], ["node2", "text"]]
# Fails: nested selectors keep the stale ids "node-1"/"node-2", and
# _collect_unresolved_refs then reports UNKNOWN_NODE_REFERENCE for both.

Covered by regression tests
TestWorkflowGeneratorIdSanitization::test_rewrites_selector_pairs_nested_in_lists
and ::test_rewrites_placeholders_inside_string_lists in
api/tests/unit_tests/core/workflow/generator/test_runner.py.

✔️ Expected Behavior

After _sanitize_node_ids, every reference to a renamed node is rewritten, including ["node-id", "var"] selector pairs and {{#id.var#}} strings that sit inside lists: the aggregator above ends up with [["node1", "text"], ["node2", "text"]] and generation proceeds.

❌ Actual Behavior

After sanitization the renamed node id no longer exists, but the nested
selector still points at the old id. The reference collector does see the
leftover pair, so _collect_unresolved_refs reports
UNKNOWN_NODE_REFERENCE (Reference {#node-1.text#} points at unknown node 'node-1') and AI workflow generation fails — even though the sanitize pass
exists precisely to repair these LLM-emitted ids and repairs them everywhere
else.

主要言語
TypeScript
スター
157k
フォーク
24.7k
平均マージ
22時間 32分
マージ済み PR(30日)
611

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

langgenius/dify のほかの issue

langgenius/dify の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。