Repository navigation
Record which controller action or job an error came from - #115
Merged
Merged
Conversation
Rails puts the current controller or job in the error context, but it was stored as "#<UsersController>". It's now the action and its filtered params, or the job's class, id, queue and filtered arguments, and records anywhere in the context are stored as GlobalIDs. Fixes #37. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Fixes #37.
Since Rails 7.1, Rails puts the current controller or job into every error's context. The sanitizer stored any object as just its class, so occurrences showed
"controller" => "#<UsersController>", and a record passed in context became"#<User>".Now:
controller: "UsersController#show"andparams, taken fromrequest.filtered_parameters, so the app'sfilter_parametersapply.job(the class),job_id,queueandarguments. Arguments go throughfilter_parameterstoo.gid://app/User/1). Unsaved records keep the class-name form.Context the app sets itself wins:
params:orarguments:passed toRails.error.set_contextaren't overwritten. Job arguments are sanitized before filtering, so a proc infilter_parameterscan't copy a record into an unsaved one and lose its GlobalID.This needs no new settings and no patching of controllers or jobs, because Rails already supplies the objects. The README gains a short section on what an occurrence records. It also answers #44: job errors already reach Solid Errors through the Rails executor with Solid Queue, Sidekiq and GoodJob.
The tests use a real request and a real job in the dummy app, and check that params and arguments are filtered. Mutants that skip the filtering or the GlobalID conversion each fail a test.
🤖 Generated with Claude Code