Make rescue_from reject meta selectors mixed with exception classes#2737
Open
ericproulx wants to merge 1 commit into
Open
Make rescue_from reject meta selectors mixed with exception classes#2737ericproulx wants to merge 1 commit into
ericproulx wants to merge 1 commit into
Conversation
1abf26f to
d6db7de
Compare
Danger ReportNo issues found. |
5d40407 to
01cebc9
Compare
Previously the `*args` signature meant that: rescue_from :all, MyError, with: :handler silently dropped `MyError`: the `if args.include?(:all)` branch fired and the trailing argument was never registered. Same for `:grape_exceptions` and `:internal_grape_exceptions`. Keep the existing `*args` signature, add a single guard above the dispatch: if any meta selector is present and `args.size > 1`, raise `ArgumentError`. Valid forms (`rescue_from :all`, `rescue_from :all, with:`, `rescue_from MyError, OtherError, with:`) are unaffected. CHANGELOG + UPGRADING entries added; three new request_response_spec examples cover the new ArgumentError contract. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
01cebc9 to
34a5f78
Compare
dblock
approved these changes
May 25, 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.
Summary
rescue_frompreviously accepted*argsand short-circuited onif args.include?(:all)(and the same for:grape_exceptions/:internal_grape_exceptions), silently dropping any exception classes passed alongside the meta selector.rescue_from :all, MyError, with: :hwould only register the:allhandler —MyErrornever bound.*argssignature, add a single guard above the dispatch: if any meta selector is present andargs.size > 1, raiseArgumentError.rescue_from :all,rescue_from :all, with: :h,rescue_from :all, &block,rescue_from MyError, OtherError, with: :h, etc.Contract change
Mixing a meta selector with exception classes now raises
ArgumentErrorinstead of silently ignoring the classes. UPGRADING entry added.Test plan
bundle exec rspec— 2316 examples, 0 failures (3 new ArgumentError specs)bundle exec rubocop— clean on touched files🤖 Generated with Claude Code