Skip to content

fix: return default object if errorsBag is undefined#78

Merged
RomainLanz merged 2 commits intoadonisjs:3.xfrom
flozdra:fix/errors-bag
Jan 29, 2026
Merged

fix: return default object if errorsBag is undefined#78
RomainLanz merged 2 commits intoadonisjs:3.xfrom
flozdra:fix/errors-bag

Conversation

@flozdra
Copy link
Copy Markdown

@flozdra flozdra commented Jan 7, 2026

🔗 Linked issue

None

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

In the following case :

  • Client: submits an invalid form.
  • Server: returns validation errors in the errors prop from the session errorsBag.
  • Client: resubmits the valid form.
  • Server: finds no errors inside the errorsBag, so the errors prop returned is undefined.
  • Client : does not update the errors prop, causing Inertia's useForm to still consider there is an error.

This PR resolves the issue by always returning an object in the #resolveValidationErrors function, ensuring the errors prop is always merged and up to date client-side.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@github-actions
Copy link
Copy Markdown

This pull request has been marked as stale because it has been inactive for more than 21 days. Please reopen if you still intend to submit this pull request

@RomainLanz
Copy link
Copy Markdown
Member

Hey @flozdra! 👋🏻

Thanks for the PR!

Are you able to add a test to ensure this works as expected?

@flozdra
Copy link
Copy Markdown
Author

flozdra commented Jan 29, 2026

Hello @RomainLanz!
I added a test case, and it does not pass without the PR changes 😉

@RomainLanz RomainLanz merged commit e898018 into adonisjs:3.x Jan 29, 2026
8 checks passed
@RomainLanz
Copy link
Copy Markdown
Member

Perfect!

Thanks 🫶

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.

2 participants