You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Snippet-inserted nodes get hyphenated IDs that the variable template regex cannot parse, so {{#nodeId.var#}} is sent to the LLM unsubstituted #43830
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.0
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
Create a workflow; add a Document Extractor node and an LLM node by inserting a Snippet (not by dragging from the block panel).
In the LLM system prompt, insert the extractor's text variable via the picker. The saved prompt contains {{#.text#}} where looks like 1791619342702-1791622662711-1.
Run the workflow with any file.
✔️ Expected Behavior
the LLM receives the extracted text.
❌ Actual Behavior
the LLM receives the literal placeholder {{#1791619342702-1791622662711-1.text#}} and replies that it cannot read the content.
Root cause:
web/app/components/workflow/block-selector/snippets/use-insert-snippet.ts (remapSnippetGraph) generates node IDs as ${node.id}-${Date.now()}-${index} — containing hyphens, unlike panel-created nodes which use pure ${Date.now()}.
The runtime template parser VARIABLE_PATTERN = r"{{#([a-zA-Z0-9_]{1,50}(?:.[a-zA-Z_][a-zA-Z0-9_]{0,29}){1,10})#}}" (core/prompt/utils/prompt_template_parser.py, and graphon.variables.template_resolution.convert_template used by the LLM node) only allows [a-zA-Z0-9_] in the node-ID segment, so hyphenated selectors never match and are passed through as plain text.
Generate hyphen-free IDs in use-insert-snippet.ts (e.g. ${Date.now()}${index}, keeping the existing collision loop but appending digits instead of -1).
Widen the node-ID character class to [a-zA-Z0-9_-]{1,50} in the template regexes (note: several independent copies exist — prompt_template_parser, app_config variables manager, rag_pipeline, workflow generator).
Fix 1 (hyphen-free IDs in the snippet insert path) looks preferable to widening the regex, for three reasons:
The workflow generator already treats [a-zA-Z0-9_] as the required ID format. Its comments say a hyphenated ID like node-1 does not match at run time, so the placeholder reaches the LLM prompt literally, and it rewrites hyphenated IDs defensively (runner.py).
The node-ID character class is copied in several places, such as WITH_VARIABLE_TMPL_REGEX in prompt_template_parser.py, plus the rag_pipeline and generator files. Widening all of them consistently is a larger, riskier change.
The ${nextId}-1 collision fallback must also change to append digits or an underscore, or it will reintroduce hyphens.
A frontend-only fix will not repair nodes already inserted, since those keep their hyphenated IDs in the saved graph. I found no documented way to rename them. A likely (unverified) workaround is to re-add the affected nodes from the block panel and re-pick the variables.
I did not read the graphonconvert_template implementation because it lives in an external package, so I'm relying on your report that it uses the same pattern.
Activity
dosubot commentedon Oct 10, 2026
Hi @ligangya1314521-ux! I'm Dosu and I'm helping the Dify team.
Your root cause matches the code.
remapSnippetGraphbuilds each new ID as${node.id}-${Date.now()}-${index}, and on a collision it appends-1repeatedly, which adds more hyphens (use-insert-snippet.ts). The backend template patterns accept only[a-zA-Z0-9_]in the node-ID segment, for example the workflow variable reference validator and the app config variables manager. Dify's notes on variable resolution describe the same failure: hyphenated node IDs pass through unsubstituted as raw text.Fix 1 (hyphen-free IDs in the snippet insert path) looks preferable to widening the regex, for three reasons:
[a-zA-Z0-9_]as the required ID format. Its comments say a hyphenated ID likenode-1does not match at run time, so the placeholder reaches the LLM prompt literally, and it rewrites hyphenated IDs defensively (runner.py).WITH_VARIABLE_TMPL_REGEXinprompt_template_parser.py, plus therag_pipelineand generator files. Widening all of them consistently is a larger, riskier change.${nextId}-1collision fallback must also change to append digits or an underscore, or it will reintroduce hyphens.A frontend-only fix will not repair nodes already inserted, since those keep their hyphenated IDs in the saved graph. I found no documented way to rename them. A likely (unverified) workaround is to re-add the affected nodes from the block panel and re-pick the variables.
I did not read the
graphonconvert_templateimplementation because it lives in an external package, so I'm relying on your report that it uses the same pattern.To reply, just mention @dosu.
Docs are dead. Just use Dosu.