You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling set_context multiple times with the same context key and the same keys within the value, the value hashes will be merged into one another. But if the same keys are used within these hashes, the new values won't overwrite the old ones.
Example:
When iterating over objects and doing possibly problematic things, I'd like to recognize which object caused the error in the resulting sentry issue. But only the first value put into the context will be submitted. In my opinion (and the usecase above), it would be more intuitive to let the new values overwrite the old ones.
* Fix context merging
When using the same key in a context hash, the new value should
overwrite the old value. Before, the value having been set first would
always win.
fixes#1722
* Add changelog
Issue Description
When calling
set_context
multiple times with the same context key and the same keys within the value, the value hashes will be merged into one another. But if the same keys are used within these hashes, the new values won't overwrite the old ones.Example:
When iterating over objects and doing possibly problematic things, I'd like to recognize which object caused the error in the resulting sentry issue. But only the first value put into the context will be submitted. In my opinion (and the usecase above), it would be more intuitive to let the new values overwrite the old ones.
Reproduction Steps
Expected Behavior
The context
:objects
should be{ object_id: 2 }
.Actual Behavior
The context
:objects
is{ object_id: 1 }
, always the first item in the list.This is due to the merge direction:
sentry-ruby/sentry-ruby/lib/sentry/scope.rb
Lines 173 to 178 in c65088f
In line 176, the merge direction should be reversed:
Ruby Version
3.0.0
SDK Version
5.1.0
Integration and Its Version
Sentry::Rack::CaptureExceptions
Sentry Config
The text was updated successfully, but these errors were encountered: