Skip to content

fix(web): accept zero in required number inputs - #43241

Open
huhumeng2 wants to merge 1 commit into
langgenius:mainfrom
huhumeng2:fix/required-number-zero
Open

huhumeng2 wants to merge 1 commit into
langgenius:mainfrom
huhumeng2:fix/required-number-zero

Conversation

@huhumeng2

Copy link
Copy Markdown

Summary

Fixes #43240.

Workflow Test Run rejects 0 for a required Number input with a required-field error. The NumberField migration in #42405 emits numeric values; the shared validator's truthiness check accepted the previous string "0" but rejects numeric 0.

Allow numeric zero through the required-input check. Add regression coverage using the real validation hook for zero, positive/negative numbers, string "0", empty values, and an unchecked required checkbox. Existing text and file-upload checks remain covered.

Validation

Verified on current main a4f949f173718974b0379dd0db8cf4401efaf8f8 plus this change:

  • Focused hook tests: 16 passed. Before the fix, only the numeric-zero case failed (1 failed, 15 passed).
  • vp run -w check: passed (0 errors; 1,580 existing warnings across the repository).
  • vp staged: passed.
  • Real browser on self-hosted source Dify 1.17.1: a User Input → Output workflow with required Number n and no default now runs with n = 0, reports success, and returns {"result": 0}. Clearing the field still shows the required-field error. The issue includes the importable DSL and the original reproduction (0 rejected, 1 succeeds).

Focused test command, from web/:

vp test run --project unit app/components/base/chat/chat/__tests__/check-input-forms-hooks.spec.tsx

Screenshots

No layout changes. Browser-verified behavior:

Before After
Entering 0 shows n必填 ("n is required") and blocks the run. The run succeeds with input n: 0 and output result: 0.

Checklist

  • Documentation update: not applicable; this restores valid Number input behavior without changing usage or configuration.
  • I understand that this PR may be closed in case there was no previous discussion or issues. Issue Workflow Test Run rejects 0 in a required Number input #43240 was filed before this fix.
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • Documentation changes: not applicable.
  • Frontend: vp staged and the complete vp run -w check passed.
  • Backend make lint && make type-check: not run; no backend code changed.

From Codex

@ghfind-review ghfind-review Bot added the review: low ghfind author score; see https://ghfind.com label Sep 29, 2026
@github-actions github-actions Bot added web This relates to changes on the web. size:M This PR changes 30-99 lines, ignoring generated files. labels Sep 29, 2026
@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.52%. Comparing base (a4f949f) to head (6580158).
⚠️ Report is 1927 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #43241   +/-   ##
=======================================
  Coverage   88.52%   88.52%           
=======================================
  Files        5184     5184           
  Lines      326028   326028           
  Branches    65435    65435           
=======================================
  Hits       288621   288621           
  Misses      32115    32115           
  Partials     5292     5292           
Flag Coverage Δ
dify-ui 93.72% <ø> (ø)
web 88.84% <100.00%> (ø)

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.

Copy link
Copy Markdown
Author

@iamjoel, could you take a look when you have time? At 6580158, this is a one-line validation fix for the required Number input regression in #43240, plus focused hook coverage.

The verification already recorded in the description includes the zero case failing before the fix, all 16 focused tests passing afterward, and a real workflow run returning 0 while an empty field still triggers the required error. The current-head Main CI Pipeline is green. Thank you!

Copy link
Copy Markdown
Author

@iamjoel @zxhlyh Following up on this small required-Number validation fix at unchanged head 6580158. Current-head Main CI Pipeline remains green, including the Web tests, browser checks, builds and E2E. The zero/empty-input regression evidence is documented in the description. Could you review when convenient? No unresolved inline feedback is pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: low ghfind author score; see https://ghfind.com size:M This PR changes 30-99 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workflow Test Run rejects 0 in a required Number input

1 participant