Skip to content

fix: preserve existing Inertia props in ShareErrors()#49

Merged
occult merged 1 commit into
mainfrom
fix/share-errors-props-override
Jan 8, 2026
Merged

fix: preserve existing Inertia props in ShareErrors()#49
occult merged 1 commit into
mainfrom
fix/share-errors-props-override

Conversation

@occult

@occult occult commented Jan 8, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a new ShareErrors() function that properly merges validation errors with existing Inertia shared props instead of overwriting them.

Changes

  • Add ShareErrors() function to pkg/form/form.go that:
    • Retrieves existing props via gonertia.PropsFromContext()
    • Merges errors into existing props map
    • Sets combined props via gonertia.SetProps()
  • Add GetErrors() method to Form interface and Submission struct
  • Add comprehensive tests for ShareErrors behavior

Why This Matters

This prevents frontend crashes when form validation fails by ensuring auth, flash, and other shared props remain available to components.

Testing

  • Added 3 new tests covering:
    • Preserving existing props when adding errors
    • Working with no existing props
    • No-op when there are no errors
  • All existing tests continue to pass

Fixes #48

Add a new ShareErrors() function that properly merges validation errors
with existing Inertia shared props instead of overwriting them.

Changes:
- Add ShareErrors() function to pkg/form/form.go that:
  - Retrieves existing props via gonertia.PropsFromContext()
  - Merges errors into existing props map
  - Sets combined props via gonertia.SetProps()
- Add GetErrors() method to Form interface and Submission struct
- Add comprehensive tests for ShareErrors behavior

This prevents frontend crashes when form validation fails by ensuring
auth, flash, and other shared props remain available to components.

Fixes #48
@occult occult merged commit 80d9e7b into main Jan 8, 2026
1 check passed
felipekafuri pushed a commit to axioms-studio/bandeira that referenced this pull request Feb 18, 2026
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.

form.ShareErrors() overwrites Inertia shared props causing frontend crashes

2 participants