fix(end-node): normalize non-string plugin content - #262
fix(end-node): normalize non-string plugin content#262openjiuwen-sync-bot[bot] wants to merge 1 commit into
Conversation
A plugin node may feed the End node a non-string payload (dict / list / number). Content.content was typed Optional[str], so such payloads failed Pydantic validation before reaching the converter — the second dialogue round could not load (#1282). - Widen Content.content to Optional[Any] (only used by End-node inputs). - end_convert now stringifies non-string content for response_template so the dumped configs stay JSON-serializable. Closes #1282. Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
|
|
|
head_sha: 变更摘要此 PR 修复了 #1282 号问题:当插件节点向 End 节点传入非字符串类型(如 主要改动
|
|
head_sha: 代码审查审查总结按优先级统计:
已审查文件:
整体风险判断:中低风险。核心归一化逻辑存在一个边界条件 bug(falsy 值),可能在插件输出
💬 仅评论 |
|
head_sha:
|
| # Normalize it to a string so the End node's response_template stays | ||
| # serializable and the second dialogue round loads correctly (#1282). | ||
| raw_content = content.content | ||
| response_template = raw_content if isinstance(raw_content, str) else str(raw_content or "") |
There was a problem hiding this comment.
head_sha: 7e71b1c1eec5cd649b284080b3bfe17006013769
🟡 Medium Priority
变更行:end.py 第 60 行 str(raw_content or "")。当插件输出 falsy 非字符串值时(False、0、0.0、[]、{}),表达式 raw_content or "" 会因 or 短路求值直接返回 "",导致 str("") = "",实际应当输出 "False"、"0"、"0.0"、"[]"、"{}"。Issue #1282 明确提到的布尔值和数字均受此影响:False 和 0 会静默丢失。
触发条件:插件节点向 End 节点输出 False / 0 / 0.0 / [] / {} 等 falsy 非 None 值。
失败模式:response_template 被设为空字符串,而非正确的字符串表示,对话历史中内容丢失。
修复方向:将 None 检查与 str() 转换分开,避免 or 吞掉 falsy 非 None 值。
建议:将 None 检查与 str() 转换解耦:先判 None → 空串,再判 str → 透传,其余 str() 转换。例如:response_template = "" if raw_content is None else raw_content if isinstance(raw_content, str) else str(raw_content)
| response_template = raw_content if isinstance(raw_content, str) else str(raw_content or "") | |
| response_template = "" if raw_content is None else raw_content if isinstance(raw_content, str) else str(raw_content) |
Paired: GitHub #262 ↔ GitCode !1812
Summary
Fixes #1282: when a plugin node feeds the End node a non-string payload (dict / list / number),
Content.contentwas typedOptional[str], so the payload failed Pydantic validation before reaching the converter — the second dialogue round could not load.Change
backend/openjiuwen_studio/schemas/node.py: widenContent.contenttoOptional[Any](theContentmodel is only used by End-nodeinputs.content, so the blast radius is contained).backend/openjiuwen_studio/core/manager/convertor/components/end.py:end_convertnow stringifies non-stringcontent.contentforresponse_template, so the dumped component configs stay JSON-serializable.Tests (
backend/tests/test_end_node_nonstring_content.py, new)5 cases:
Nonecontent → emptyresponse_templateVerification
uv run pytest backend/tests/test_end_node_nonstring_content.py— 5 passedLinked Closing Issues: