Conversation
插件/工具/工作流节点的 JSON Editor 之前按普通文本替换变量。
变量里的引号、换行、反斜杠会弄坏 JSON,valueTypeFormat 把 object/array 解析成 {}。
与 HTTP JSON Body 共用同一套按引号转义的替换。
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Collaborator
|
不再对双花括号内容进行进一步适配和处理,该变量引用方式已被弃用,目前都使用文本输入框/引用变量 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
现象
插件、工具、工作流节点上的 JSON Editor 可以写
{{变量}}。变量值里一旦有引号、换行或反斜杠,运行时 object / array 入参会变成空对象{}。例如 JSON Editor 内容是:
{"name": "{{userName}}"}userName为Ada "Lovelace"时,节点实际拿到的是{},不是{ "name": "Ada \"Lovelace\"" }。下游工具、插件、HTTP 请求都会丢字段。JSON Editor 的补全会插入
{{key}},这个路径很常见。原因
getWorkflowNodeRunParams对所有带{{的字符串都走replaceEditorVariable。那是普通文本替换,不会按 JSON 转义。替换后的文本不再是合法 JSON,
valueTypeFormat对 object 解析失败就返回{},对 array 会把整段坏 JSON 再包一层数组。HTTP 节点的 JSON Body 已经有
replaceJsonBodyString,会看变量是否在引号内再转义。JSON Editor 入参没有走这条路径。修改
replaceJsonBodyStringreplaceJsonBodyString抽到dispatch/utils,HTTP JSON Body 和节点 JSON 入参共用验证
新增
packages/service/test/core/workflow/dispatch/utils/runtime.test.ts,并回归http.test.ts里原有的 JSON Body 替换用例。{}prettier与git diff --check通过。AI-assisted (Grok)