{"action":"closed","issue":{"url":"https://api.github.com/repos/getsentry/raven-ruby/issues/592","repository_url":"https://api.github.com/repos/getsentry/raven-ruby","labels_url":"https://api.github.com/repos/getsentry/raven-ruby/issues/592/labels{/name}","comments_url":"https://api.github.com/repos/getsentry/raven-ruby/issues/592/comments","events_url":"https://api.github.com/repos/getsentry/raven-ruby/issues/592/events","html_url":"https://github.com/getsentry/raven-ruby/issues/592","id":190990328,"number":592,"title":"Can't modify frozen Hash error using 2.1+ in conjunction with Raven::Processor::SanitizeData","user":{"login":"jsdalton","id":235836,"avatar_url":"https://avatars.githubusercontent.com/u/235836?v=3","gravatar_id":"","url":"https://api.github.com/users/jsdalton","html_url":"https://github.com/jsdalton","followers_url":"https://api.github.com/users/jsdalton/followers","following_url":"https://api.github.com/users/jsdalton/following{/other_user}","gists_url":"https://api.github.com/users/jsdalton/gists{/gist_id}","starred_url":"https://api.github.com/users/jsdalton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsdalton/subscriptions","organizations_url":"https://api.github.com/users/jsdalton/orgs","repos_url":"https://api.github.com/users/jsdalton/repos","events_url":"https://api.github.com/users/jsdalton/events{/privacy}","received_events_url":"https://api.github.com/users/jsdalton/received_events","type":"User","site_admin":false},"labels":[{"id":2713101,"url":"https://api.github.com/repos/getsentry/raven-ruby/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-11-22T12:45:43Z","updated_at":"2016-11-22T15:53:19Z","closed_at":"2016-11-22T15:53:19Z","body":"We experienced a critical issue today when upgrading Sentry to version 2.1.3. Calls to `capture_exception` from our Rails application started failing with \"RuntimeError: can't modify frozen Hash\" errors.\r\n\r\nHere is the full stacktrace we get when reproducing the error from a console:\r\n\r\n```\r\nirb(main):004:0> Raven::VERSION\r\n=> \"2.1.3\"\r\nirb(main):005:0> Raven.capture_exception Exception.new('Boom!')\r\nRuntimeError: can't modify frozen Hash\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/processor/sanitizedata.rb:18:in `block in process'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/processor/sanitizedata.rb:18:in `each'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/processor/sanitizedata.rb:18:in `each_with_object'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/processor/sanitizedata.rb:18:in `process'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/processor/sanitizedata.rb:23:in `sanitize'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/processor/sanitizedata.rb:18:in `block in process'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/processor/sanitizedata.rb:18:in `each'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/processor/sanitizedata.rb:18:in `each_with_object'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/processor/sanitizedata.rb:18:in `process'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/client.rb:66:in `block in encode'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/client.rb:66:in `each'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/client.rb:66:in `reduce'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/client.rb:66:in `encode'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/client.rb:37:in `send_event'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/instance.rb:88:in `send_event'\r\n        from /var/lib/gems/2.1.0/gems/sentry-raven-2.1.3/lib/raven/instance.rb:131:in `capture_type'\r\n... 11 levels...\r\n        from /var/lib/gems/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `load'\r\n        from /var/lib/gems/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `block in load'\r\n        from /var/lib/gems/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'\r\n        from /var/lib/gems/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `load'\r\n        from /var/lib/gems/2.1.0/gems/spring-2.0.0/lib/spring/commands/rails.rb:6:in `call'\r\n        from /var/lib/gems/2.1.0/gems/spring-2.0.0/lib/spring/command_wrapper.rb:38:in `call'\r\n        from /var/lib/gems/2.1.0/gems/spring-2.0.0/lib/spring/application.rb:191:in `block in serve'\r\n        from /var/lib/gems/2.1.0/gems/spring-2.0.0/lib/spring/application.rb:161:in `fork'\r\n        from /var/lib/gems/2.1.0/gems/spring-2.0.0/lib/spring/application.rb:161:in `serve'\r\n        from /var/lib/gems/2.1.0/gems/spring-2.0.0/lib/spring/application.rb:131:in `block in run'\r\n        from /var/lib/gems/2.1.0/gems/spring-2.0.0/lib/spring/application.rb:125:in `loop'\r\n        from /var/lib/gems/2.1.0/gems/spring-2.0.0/lib/spring/application.rb:125:in `run'\r\n        from /var/lib/gems/2.1.0/gems/spring-2.0.0/lib/spring/application/boot.rb:19:in `<top (required)>'\r\n        from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'\r\n        from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'\r\n        from -e:1:in `<main>'\r\n```\r\n\r\n## Cause\r\n\r\nAfter debugging the issue further, we determined that the problem was introduced in dc6d983f413572a0871cf6e8895e0eb8e7fdb4dd, specifically here:\r\n\r\nhttps://github.com/getsentry/raven-ruby/blob/dc6d983f413572a0871cf6e8895e0eb8e7fdb4dd/lib/raven/event.rb#L24\r\n\r\nThe error occurs specifically when using sentry-raven version 2.1+ with the `Raven::Processor::SanitizeData` as a processor:\r\n\r\n```ruby\r\n  Raven.configure do |config|\r\n    ...\r\n    config.processors = [Raven::Processor::SanitizeData]\r\n    ...\r\n  end\r\n\r\n```\r\n\r\nThe error occurs because the `sanitize` method in the `SanitizeData` processor attempts to recursively sanitize and update the entire event data hash being sent to Sentry. When this method encounters the new `:sdk` data hash, it attempts to overwrite one of the values within it. Because the `:sdk` value itself is set here from a class constant which is frozen (i.e. `Raven::Event::SDK`):\r\n\r\nhttps://github.com/getsentry/raven-ruby/blob/dc6d983f413572a0871cf6e8895e0eb8e7fdb4dd/lib/raven/event.rb#L223\r\n\r\n ...a `RuntimeError` is raised since it's trying to modify the hash.\r\n\r\nWe have reverted to `2.0.2` because we depend upon the sanitization processing, but hope to be able to get back to the latest version if/when this issue is resolved.\r\n"}}
{"actor":{"display_login":"nateberkopec"}}