dify icon indicating copy to clipboard operation
dify copied to clipboard

Workflow run output panel double-encodes structured JSON

Open wzxsdf opened this issue 2 weeks ago • 2 comments

Summary

Structured workflow run outputs are rendered as an escaped JSON string in the output code editor, rather than as a JSON object.

Source-based reproduction

web/app/components/workflow/run/output-panel.tsx passes JSON.stringify(outputs, null, 2) to CodeEditor while enabling isJSONStringifyBeauty. CodeEditor calls serializeCodeEditorValue(value, true), which serializes that string again. For { "answer": "hello", "score": 1 }, the editor therefore receives a quoted string containing escaped newlines and quotes.

The existing test web/app/components/workflow/run/__tests__/output-panel.spec.tsx marks the expected structured JSON behavior with it.fails, confirming this known gap in the current default branch.

Expected

The editor displays a JSON object with normal indentation, and parsing its value yields the original output object.

Proposed fix

Pass the output object directly to CodeEditor and enable the existing regression test. The editor already owns JSON serialization.

I checked for a matching open Issue or PR before filing this.

wzxsdf avatar Nov 19 '26 15:11 wzxsdf

Nice catch. Passing outputs directly to <CodeEditor value={outputs} isJSONStringifyBeauty /> is the right call here since serializeCodeEditorValue handles the formatting internally.

Un-skipping the test in web/app/components/workflow/run/__tests__/output-panel.spec.tsx (switching it.fails back to it) and running pnpm test web/app/components/workflow/run/__tests__/output-panel.spec.tsx should be all that's needed.

If you're planning to open the PR for this, go for it—it's a clean, zero-friction fix.

grinem avatar Nov 19 '26 17:11 grinem

Hi @wzxsdf, thanks for opening this issue.

Why this is being closed

The code analysis and test reference are helpful, but the report does not identify the Dify version or commit, deployment type, or steps and observed results from a running workflow. That context is needed to verify the affected setup. The bug report template asks for version, deployment and reproduction details. We are closing this while that context is gathered; this is not a judgment that the underlying observation is incorrect.

Next steps

Please update the report with the missing details, the precise steps and observed versus expected results, and any relevant sanitized logs or test output. If this is a source-only reproduction, please say so explicitly and include the exact commit and how to run it. Then request reopening so the report and linked work can be reviewed.

crazywoola avatar Nov 20 '26 03:11 crazywoola