Skip to content

fix(web): omit empty optional agent variable inputs - #44748

Merged
lyzno1 merged 1 commit into
langgenius:mainfrom
okht:codex/fix-agent-optional-variable
Oct 26, 2026
Merged

lyzno1 merged 1 commit into
langgenius:mainfrom
okht:codex/fix-agent-optional-variable

Conversation

@okht

@okht okht commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

fix #44742
fix #44579

Clearing an optional any input in a legacy Workflow/Chatflow Agent node leaves an empty variable reference in the saved graph. An untouched optional input with default: null can also become an empty reference when another form field changes. This change omits those entries at the Agent form serialization boundary, restoring the unconfigured state.

Refs #44579. The issue author, @ZhXZhao, has described a locally verified Agent-specific frontend fix. This PR independently implements the narrow frontend serialization portion and adds regression coverage. It complements #44655's backend handling of existing saved configurations. The broader nested manual-tool parameter path and the full MCP remove/re-add sequence in #44742 remain outside this change.

Only parameters present in the submitted form values and declared as optional any are omitted when their selector is '', null, or []. Required inputs, nonempty references, ordinary constants, tool lists, nested automatic tool parameters, and unknown saved fields retain their existing behavior. Non-null strategy-default encoding is unchanged.

Validation:

  • Reproduced both serialization failures on unmodified main before applying the fix.
  • Agent unit suite: 5 files, 25 tests passed, including 6 tests using the production panel, form, variable picker, and graph store.
  • vp run -w check and vp staged passed.
  • Web type checking passed using the matching official @tsrs/wasm version (0.18.0-ts7.1.0-dev.20260929); the native tsrs package has no Windows executable.
  • Reopening is tested by serializing graph data, unmounting, and mounting a fresh panel. Server persistence and full workflow execution were not tested.

Screenshots

The visible empty field is unchanged; the observable change is the serialized graph data:

Before After
{"context":{"type":"variable","value":""}} after clearing {}
{"context":{"type":"variable","value":null},"enabled":{"type":"constant","value":false}} after editing another field {"enabled":{"type":"constant","value":false}}

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

The documentation items are not applicable to this serialization bug fix. The final checklist item applies to vp staged; no backend files changed.

From Codex

@okht
okht requested review from iamjoel and zxhlyh as code owners October 25, 2026 13:30
@github-actions github-actions Bot added web This relates to changes on the web. size:L This PR changes 100-499 lines, ignoring generated files. labels Oct 25, 2026
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.40%. Comparing base (12ab116) to head (b638429).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #44748   +/-   ##
=======================================
  Coverage   89.39%   89.40%           
=======================================
  Files        5986     5986           
  Lines      375177   375182    +5     
  Branches    76081    76083    +2     
=======================================
+ Hits       335408   335420   +12     
+ Misses      33732    33725    -7     
  Partials     6037     6037           
Flag Coverage Δ
dify-ui 92.38% <ø> (ø)
web 89.45% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lyzno1
lyzno1 enabled auto-merge October 26, 2026 03:15
@lyzno1
lyzno1 added this pull request to the merge queue Oct 26, 2026
Merged via the queue into langgenius:main with commit 2edd56a Oct 26, 2026
51 checks passed
hjlarry pushed a commit that referenced this pull request Oct 26, 2026
@laipz8200 laipz8200 mentioned this pull request Nov 3, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

2 participants