Repository navigation
Drop to_hash in SentryParameterFilter to support sentry-ruby v6 - #22
Conversation
|
@os0x Sorry to jump in from the side, but I ran into the same issue. It might be helpful to update the sample code in the README as well. Apologies for only leaving a comment instead of sending a patch myself. thanks a lot! |
There was a problem hiding this comment.
Pull request overview
Updates Blouson’s SentryParameterFilter to operate directly on Sentry::Event / Sentry::RequestInterface objects instead of event.to_hash, aligning with sentry-ruby v6 where to_hash is removed.
Changes:
- Refactored
SentryParameterFilterinternals to useevent.request.*andevent.extrarather than hash access. - Updated specs to construct and assert against real
Sentry::ErrorEvent+Sentry::RequestInterfaceobjects.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/blouson/sentry_parameter_filter.rb | Switches filtering logic from hash-based event access to Sentry object accessors. |
| spec/blouson/sentry_parameter_filter_spec.rb | Reworks test setup/assertions to use Sentry event/request objects and validate the new behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nekketsuuu
left a comment
There was a problem hiding this comment.
Mostly LGTM. Would you please add a lower bound of sentry-ruby gem in gemspec?
| return unless req && req.data.present? | ||
|
|
||
| data = req.data | ||
| if data.is_a?(String) |
There was a problem hiding this comment.
Memo: I think it's okay to leave this condition as is, but it seems that Sentry::RequestInterface expects data is a Hash: https://github.com/getsentry/sentry-ruby/blob/a1c52820777d5ddb151ba66fd55cced0732730fd/sentry-ruby/lib/sentry/interfaces/request.rb#L24-L26
There was a problem hiding this comment.
Although it's annotated as @return [Hash] , looking at the read_data_from implementation, there are several cases where it returns a String:
- Non-form-data requests (e.g. JSON): request.body.read → String
- Non-rewindable body: "Skipped non-rewindable request body" → String
- IOError: e.message → String
So the data.is_a?(String) check is still necessary.
|
|
||
| ``` | ||
|
|
||
| > **Note:** Since sentry-ruby v6, `event.to_hash` is no longer available. Pass `event` directly to `filter.process` instead of `filter.process(event.to_hash)`. |
There was a problem hiding this comment.
nit: I think this should be written in CHANGELOG instead of README
There was a problem hiding this comment.
This is an important breaking change, so it would be good to document it in both the README and CHANGELOG.
Access Sentry::Event and Sentry::RequestInterface objects directly instead of converting via to_hash, which is deprecated in v5 and removed in v6. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tibility Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…spec Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5575cad to
d63dd84
Compare
Done! I've added >= 6.0 as the lower bound of sentry-ruby in gemspec. |
|
Since it's a development_dependency, users can still bundle install with sentry-ruby v5 or earlier. require 'sentry-ruby'
gem_version = Gem.loaded_specs['sentry-ruby']&.version
if gem_version && gem_version < Gem::Version.new('6.0')
raise "blouson's SentryParameterFilter requires sentry-ruby >= 6.0 (you have #{gem_version})"
endWhat do you think? |
|
I think it is sufficient to mention it in the changelogs. In any case, it will cause an error because of to_hash. |
|
Thanks for your fix! |
Summary
SentryParameterFilter#processfrom hash access (event[:request][:data], etc.) to direct object access onSentry::Event/Sentry::RequestInterface(event.request.data, etc.)to_hashin sentry-ruby v5 and its removal in v6filter.process(event.to_hash)tofilter.process(event)(breaking change — major version bump planned)Test plan
spec/blouson/sentry_parameter_filter_spec.rbto useSentry::ErrorEvent+Sentry::RequestInterfaceobjects instead of plain hashes🤖 Generated with Claude Code