fix(rails): ensure Rails.error.set_context is not lost#3024
Conversation
0b442b1 to
c29006f
Compare
c29006f to
69d3b44
Compare
| end | ||
|
|
||
| { "rails.error" => sanitized } | ||
| end |
There was a problem hiding this comment.
Tags and hint context ignored
Medium Severity
ErrorReporterContext.contexts dumps the full ExecutionContext into rails.error, but unlike ErrorSubscriber it never lifts tags or hint out of that hash. For unhandled exceptions and ActiveJob failures, CaptureExceptions/ActiveJob usually win the capture race, so Rails.error.set_context(tags: ...) / hint: ... still never become real Sentry tags or hints.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 22f13b0. Configure here.
There was a problem hiding this comment.
That's material for a follow-up PR.
22f13b0 to
bb0629b
Compare
b314e12 to
de0ec18
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit de0ec18. Configure here.
| return {} if execution_context.empty? | ||
|
|
||
| { "rails.error" => Sentry::Rails::Serializer.serialize(execution_context) } | ||
| end |
There was a problem hiding this comment.
Unsanitized ExecutionContext breaks event send
High Severity
ErrorReporterContext.contexts dumps the full ActiveSupport::ExecutionContext through Serializer, which leaves non-primitive values unchanged. Rails always stores the live controller (and job) instance there, so those objects land in rails.error and can make JSON.generate fail when the event is actually sent—dropping the report. Specs miss this because DummyTransport never serializes envelopes.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit de0ec18. Configure here.
There was a problem hiding this comment.
@neel so I reduced this to a regular serializer and this popped up again - it's legit, the context does include by default a full controller instance or an AJ job instance. They'd go through regular JSON serialization path ending up as "#<HelloController:0x0000ffff627e4610>" etc. - we OK with that?


Use
ActiveSupport::ExecutionContextto maintain in the context what's set viaRails.error.set_context.Closes #2931