Skip to content

fix(form): whole-form refine() errors block submit (#897) - #980

Merged
escape-llc merged 1 commit into
mainfrom
fix/897-form-level-errors
Nov 23, 2026
Merged

escape-llc merged 1 commit into
mainfrom
fix/897-form-level-errors

Conversation

@escape-llc

Copy link
Copy Markdown
Owner

Closes #897 (weekly Gemini audit, Form Controls — Composite).

Finding 1: confirmed, fixed

A whole-form .refine()/.superRefine() with no path reports path: []. parseValues dropped it (if (fieldPath && ...)), so the error map came back empty and handleSubmit treated an invalid form as valid: onSubmit ran with raw values that had failed the schema.

  • parseValues now keeps a pathless issue under the exported FORM_ERROR_KEY ('', the path it joins to; no field name is empty). The form is invalid, form:errored carries it, and submit is blocked.
  • The summary <FormError> (no name) shows that message instead of the generic text.
  • Regression tests in Form.test.tsx: mismatched passwords block submit and show "Passwords must match"; matching ones submit.

Finding 2: false positive, AGENTS.md corrected

--ai-subtheme-error-on-main is defined (harmonies.ts:446). The audit applied AGENTS.md's "the convention is -text, not on-*" note, which is true for the harmony roles but not for subthemes. That paragraph now names the subtheme exception and carries a three-part entry for this false positive.

🤖 Generated with Claude Code

A schema-level refine/superRefine with no path reports path [], which
parseValues dropped: the error map came back empty and an invalid form
submitted. Keep it under FORM_ERROR_KEY (''); the summary FormError shows
its message. AGENTS.md: subthemes' -on-main variables are real (the
audit's second finding was a false positive from the on-* note).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🔎 Gemini review (gemini-3-flash-preview)

Review metadata
kind: gemini-review
schema: 1
model: gemini-3-flash-preview
pr: 980
head_sha: 502d6895d755754711839d3a6006e1344d22d94e
run_id: 45184878722
run_attempt: 1
created_at: 2026-11-23T13:32:53Z
diff_bytes: 11110
history_bytes: 0
omitted_generated_files: 2
review_chars: 726

The logic changes in FormContext.tsx and FormComponents.tsx correctly address the issue where whole-form Zod refinements (those with an empty path) were silently ignored. By allowing the empty string key in the error map and updating the summary FormError to display the specific refinement message, the form now properly blocks submission and provides actionable feedback for cross-field validation failures.

The regression tests in Form.test.tsx thoroughly verify both the failure state and the subsequent successful submission once refinements pass. The updates to AGENTS.md provide clear, necessary guidance to avoid future false positives regarding subtheme variable naming conventions.

No defects identified.

@escape-llc
escape-llc merged commit f455272 into main Nov 23, 2026
25 checks passed
@escape-llc
escape-llc deleted the fix/897-form-level-errors branch November 23, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weekly Gemini audit: Form Controls — Composite (week of 2026-11-09)

1 participant