Improve user-facing error messages for invalid tokens #2572
mroderick
started this conversation in
Maintenance
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
PR #2529 (recently merged) fixed a production crash where invalid invitation tokens caused 500 errors (
NoMethodError: undefined method 'member' for nil). The fix changedfind_bytofind_by!in before_action callbacks, so invalid tokens now return a proper 404 response.The Problem
In the PR review, @till raised a valid UX concern:
Currently, users visiting
/invitations/invalid-tokensee:This message is generic and doesn't explain:
Proposed Solution
Create a custom exception (
CodebarResourceNotFound) that carries a user-friendly message, plus a new error template that displays context-specific text.Example messages by resource type:
Implementation Approach
lib/codebar_errors.rbwithCodebarResourceNotFoundexception classApplicationControllerfor this custom exceptionerrors/not_found_user_friendly.html.haml) showing the custom messageWorkshopInvitationConcerns#set_invitationto raise the custom exception instead of letting Rails return generic 404WorkshopInvitationConcerns)This is a low-risk improvement that can be extended to other resource types (events, meetings, feedback requests) in future phases.
Questions for Discussion
Beta Was this translation helpful? Give feedback.
All reactions