Skip to content

fix(inertia,hosting): key validation errors by form field, first message wins; honour error bags (#776, #777) - #799

Merged
antosubash merged 7 commits into
mainfrom
fix/inertia-validation-errors-776-777
Nov 3, 2026
Merged

antosubash merged 7 commits into
mainfrom
fix/inertia-validation-errors-776-777

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Fixes how form validation errors reach Inertia pages (tracking #780).

Closes #776
Closes #777

What changed

  • hosting: validation_errors_to_dict keys errors by union type / list index and keeps the last message #776 Error keys and messages: a new simple_module_inertia.errors_from_validation() keys each pydantic error by its top-level form field and keeps the first message per field, as Laravel does.
    • Union-member tags (("quantity", "int")), list indices and nested-model segments no longer become keys. Before, a union field's error landed under int/bool and no form showed it.
    • The leading FastAPI body/query/… segment is dropped only for a RequestValidationError (request_source=True), so a model field really named path keeps its key.
    • Both simple_module_hosting.inertia_utils.validation_errors_to_dict and the adapter's validation handler use it.
  • hosting: redirect_back_with_errors ignores X-Inertia-Error-Bag #777 Error bags: redirect_back_with_errors nests errors under X-Inertia-Error-Bag through a shared scope_errors(). An empty header means no bag, matching InertiaRequest.error_bag.
  • Found in QA (existed before this PR): the settings override Create/Edit forms never rendered model-level errors, which arrive under errors.general (e.g. "tenant/user scope requires a scope_id"). The submit silently bounced back to the form. A new FormLevelError component shows them, with pydantic's "Value error, " prefix stripped through a shared helper.

Callers checked: permissions and settings pages read only top-level keys (value, key, scope, scope_id, permissions, delete, errors[f.name]). No page sets errorBag.

Verification

  • make lint ✓ · make test-py (8 workers): 7320 passed, 43 skipped ✓ · make test-js: 886 passed ✓
  • The issue repros (union/list keys, error bag round-trip) now pass.
  • Browser QA (shallow, 2 iterations):
    • settings module field errors appear under the right field;
    • the settings-store create form now shows the model-level error, field-level errors still sit under their fields, and the edit form layout is intact.
    • 1 bug found (the errors.general rendering above) and fixed, re-test PASS.
  • Review: two rounds of correctness and maintainability review. Every finding was fixed or rejected with evidence.

Not changed here (separate, existing behaviour): the settings store accepts override keys of any format (e.g. Bad Key!!).

https://claude.ai/code/session_01FXHA3ZJ5EgoJN4zXTAhBR2

…age wins; honour error bags (#776, #777)

- New simple_module_inertia.errors_from_validation: one key per top-level
  form field (union-member tags, list indices and nested-model segments no
  longer become keys), first message per field as Laravel does. The leading
  body/query/... segment is dropped only for RequestValidationError, so a
  model field really named 'path' keeps its key.
- validation_errors_to_dict and the adapter's validation handler share it.
- redirect_back_with_errors nests errors under X-Inertia-Error-Bag.

Claude-Session: https://claude.ai/code/session_01FXHA3ZJ5EgoJN4zXTAhBR2
…n-errors-776-777

# Conflicts:
#	CHANGELOG.md
- empty X-Inertia-Error-Bag means no bag; shared scope_errors() helper for both callers
- drop the 'form' request source FastAPI never emits
- docstring and CHANGELOG note the new helpers

Claude-Session: https://claude.ai/code/session_01FXHA3ZJ5EgoJN4zXTAhBR2
… the override forms

A model validator error (e.g. 'tenant/user scope requires a scope_id') has an
empty loc and is flashed under errors.general, which neither Create nor Edit
rendered, so the submit silently bounced back. Found by /ship QA on #776.

Claude-Session: https://claude.ai/code/session_01FXHA3ZJ5EgoJN4zXTAhBR2
- strip pydantic's 'Value error, ' prefix via a shared stripValueErrorPrefix helper
- CHANGELOG entry for the settings form-level error

Claude-Session: https://claude.ai/code/session_01FXHA3ZJ5EgoJN4zXTAhBR2
…n-errors-776-777

# Conflicts:
#	CHANGELOG.md
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-03T18:31:22.384639Z 1aeaef0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 620f3e1
Status: ✅  Deploy successful!
Preview URL: https://d9406f1a.simple-module-python.pages.dev
Branch Preview URL: https://fix-inertia-validation-error.simple-module-python.pages.dev

View logs

…n-errors-776-777

# Conflicts:
#	CHANGELOG.md
@antosubash
antosubash merged commit acea646 into main Nov 3, 2026
16 checks passed
@antosubash
antosubash deleted the fix/inertia-validation-errors-776-777 branch November 3, 2026 18: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

1 participant