Uh oh!
There was an error while loading. Please reload this page.
Return a 422 error when not_expected is called without a split name - #2226
Merged
Merged
Conversation
FindNotExpectedBibs crashed with NoMethodError when the split_name param was missing, turning a malformed API request into a 500. Parameterize nil-safely so the existing split name validation produces its normal error response. Also replace OpenStruct with a Response struct and use a guard clause in validate_setup to clear pre-existing rubocop offenses. Resolves#2224 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Summary
Fixes the production 500 captured in Scout error group 123521:
GET /api/v1/event_groups/:id/not_expectedwithout asplit_nameparam crashed withNoMethodError: undefined method 'parameterize' for nil.FindNotExpectedBibsnow parameterizes the split name nil-safely, so a missing split name falls through to the existingvalidate_setupinclusion check and the controller renders its normal 422 with the "Invalid split name" error body.OpenStructwith aResponsestruct (matching theStruct.newconvention used elsewhere in the app) and convertsvalidate_setupto a guard clause.Resolves#2224
Testing
bundle exec rspec spec/services/find_not_expected_bibs_spec.rb— 3 examples, 0 failures🤖 Generated with Claude Code