Turn over-length registration answers into form errors, not 500s#1763
Merged
Conversation
A registration answer longer than its mapped varchar(255) column (e.g. a long city) raised ActiveRecord::ValueTooLong — a StatementInvalid, which the service's RecordInvalid/RecordNotUnique rescues don't catch — so it surfaced as a 500 mid-registration instead of letting the registrant correct it. Rescue ValueTooLong in PublicRegistration and return a failed result with a friendly, column-named message; the controller already re-renders the form with that error. The column can't always be mapped back to a single field (mailing and agency addresses both write `city`), so the message names the column. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
maebeale
commented
Jun 19, 2026
| Result.new(success?: true, event_registration: event_registration, form_submission: submission, errors: []) | ||
| end | ||
| rescue ActiveRecord::ValueTooLong => e | ||
| Result.new(success?: false, event_registration: nil, errors: [ too_long_message(e) ]) |
Collaborator
Author
There was a problem hiding this comment.
🤖 From Claude: ValueTooLong is a StatementInvalid, not a RecordInvalid, so it needs its own rescue — otherwise an answer longer than its varchar(255) column 500s mid-registration instead of re-rendering the form.
2 tasks
jmilljr24
approved these changes
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes [link an issue or remove this line]
What is the goal of this PR and why is this important?
varchar(255)column (e.g. a long city) raisedActiveRecord::ValueTooLongmid-registration and surfaced as a 500, with no way for the registrant to recover.ValueTooLongis aStatementInvalid, which the service's existingRecordInvalid/RecordNotUniquerescues don't catch — so it escaped the normal "re-render the form with an error" path.How did you approach the change?
EventRegistrationServices::PublicRegistrationnow rescuesActiveRecord::ValueTooLongand returns a failed result with a friendly, column-named message ("Your city is too long. Please shorten it and try again."). The controller already re-renders the form with that error, so it flows through as an ordinary form validation error.city), so the message names the column rather than guessing a field.UI Testing Checklist
Anything else to add?