Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentError: redundant UTF-8 sequence #85

Closed
fschwahn opened this issue Jan 21, 2014 · 12 comments
Closed

ArgumentError: redundant UTF-8 sequence #85

fschwahn opened this issue Jan 21, 2014 · 12 comments
Labels

Comments

@fschwahn
Copy link

Hi,
I'm not sure this is a rollbar issue, but it's the only dependency turning up in the stacktrace. I'm using version 0.11.7 - I know there are newer versions, but I hesitate to update because there were quite a few regressions.

Here's the stacktrace:

File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 130 in unpack
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 130 in block in escape
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 125 in gsub
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 125 in escape
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 69 in escape
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 177 in encode_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 48 in block in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 77 in check_for_circular_references
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 46 in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in block in encode_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in each
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in map
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in encode_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 48 in block in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 77 in check_for_circular_references
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 46 in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in block in encode_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in each
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in map
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in encode_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 48 in block in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 77 in check_for_circular_references
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 46 in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in block in encode_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in each
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in map
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in encode_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 48 in block in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 77 in check_for_circular_references
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 46 in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in block in encode_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in each
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in map
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in encode_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 48 in block in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 77 in check_for_circular_references
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 46 in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in block in encode_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in each
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in map
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 252 in encode_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 48 in block in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 77 in check_for_circular_references
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 46 in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/json/encoding.rb" line 31 in encode
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/core_ext/object/to_json.rb" line 16 in to_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/multi_json-1.8.4/lib/multi_json/adapters/json_common.rb" line 21 in dump
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/multi_json-1.8.4/lib/multi_json/adapter.rb" line 24 in dump
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/multi_json-1.8.4/lib/multi_json.rb" line 137 in dump
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar.rb" line 338 in build_payload
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar.rb" line 89 in report_exception
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar/exception_reporter.rb" line 9 in report_exception_to_rollbar
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar/middleware/rails/show_exceptions.rb" line 22 in rescue in call_with_rollbar
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar/middleware/rails/show_exceptions.rb" line 19 in call_with_rollbar
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/show_exceptions.rb" line 56 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/rack/logger.rb" line 32 in call_app
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/rack/logger.rb" line 16 in block in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/tagged_logging.rb" line 22 in tagged
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/rack/logger.rb" line 16 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/request_id.rb" line 22 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb" line 21 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/runtime.rb" line 17 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/cache/strategy/local_cache.rb" line 72 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/lock.rb" line 15 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 136 in forward
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 143 in pass
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 155 in invalidate
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 71 in call!
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 51 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/engine.rb" line 484 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/application.rb" line 231 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/railtie/configurable.rb" line 30 in method_missing
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 530 in process_client
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 604 in worker_loop
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 487 in spawn_missing_workers
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 137 in start
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.2.1/bin/unicorn" line 121 in <top (required)>
File "/path/to/app/shared/bundle/ruby/1.9.1/bin/unicorn" line 23 in load
File "/path/to/app/shared/bundle/ruby/1.9.1/bin/unicorn" line 23 in <main>

Thanks!
Fabian

@coryvirok
Copy link
Contributor

Thanks Fabian. We'll take a look.

@fschwahn
Copy link
Author

Alright, I also occasionally get this exception, it is possibly related: JSON::GeneratorError: source sequence is illegal/malformed utf-8. Missing from my original post is the information that I'm using the sidekiq backend, and I'm on version 2.16.1 of sidekiq.

The stacktrace is the following:

File "/path/to/app/shared/bundle/ruby/1.9.1/gems/json-1.8.1/lib/json/common.rb" line 223 in generate
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/json-1.8.1/lib/json/common.rb" line 223 in generate
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/sidekiq-2.16.1/lib/sidekiq.rb" line 105 in dump_json
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 157 in block (2 levels) in raw_push
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 157 in map
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 157 in block in raw_push
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/connection_pool-1.1.0/lib/connection_pool.rb" line 49 in with
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/sidekiq-2.16.1/lib/sidekiq.rb" line 67 in redis
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 149 in raw_push
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 50 in push
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 97 in push
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar/delay/sidekiq.rb" line 11 in handle
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar.rb" line 327 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar.rb" line 327 in schedule_payload
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar.rb" line 90 in report_exception
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar/exception_reporter.rb" line 9 in report_exception_to_rollbar
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar/middleware/rails/show_exceptions.rb" line 22 in rescue in call_with_rollbar
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rollbar-0.11.7/lib/rollbar/middleware/rails/show_exceptions.rb" line 19 in call_with_rollbar
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/show_exceptions.rb" line 56 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/rack/logger.rb" line 32 in call_app
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/rack/logger.rb" line 16 in block in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/tagged_logging.rb" line 22 in tagged
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/rack/logger.rb" line 16 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/request_id.rb" line 22 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb" line 21 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/runtime.rb" line 17 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/cache/strategy/local_cache.rb" line 72 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/lock.rb" line 15 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 136 in forward
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 143 in pass
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 155 in invalidate
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 71 in call!
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 51 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/engine.rb" line 484 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/application.rb" line 231 in call
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/railtie/configurable.rb" line 30 in method_missing
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 530 in process_client
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 604 in worker_loop
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 487 in spawn_missing_workers
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 137 in start
File "/path/to/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.2.1/bin/unicorn" line 121 in <top (required)>
File "/path/to/app/shared/bundle/ruby/1.9.1/bin/unicorn" line 23 in load
File "/path/to/app/shared/bundle/ruby/1.9.1/bin/unicorn" line 23 in <main>

@fschwahn
Copy link
Author

I just want to bump this, I'm still getting these errors occasionally, also with newer versions of the rollbar gem, currently 0.12.12. Relevant stacktrace:

JSON::GeneratorError: source sequence is illegal/malformed utf-8
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/json-1.8.1/lib/json/common.rb" line 223 in generate
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/json-1.8.1/lib/json/common.rb" line 223 in generate
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/sidekiq-2.16.1/lib/sidekiq.rb" line 105 in dump_json
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 157 in block (2 levels) in raw_push
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 157 in map
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 157 in block in raw_push
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/connection_pool-1.1.0/lib/connection_pool.rb" line 49 in with
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/sidekiq-2.16.1/lib/sidekiq.rb" line 67 in redis
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 149 in raw_push
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 50 in push
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/sidekiq-2.16.1/lib/sidekiq/client.rb" line 97 in push
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rollbar-0.12.12/lib/rollbar/delay/sidekiq.rb" line 13 in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rollbar-0.12.12/lib/rollbar.rb" line 349 in schedule_payload
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rollbar-0.12.12/lib/rollbar.rb" line 108 in report_exception
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rollbar-0.12.12/lib/rollbar/exception_reporter.rb" line 9 in report_exception_to_rollbar
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rollbar-0.12.12/lib/rollbar/middleware/rails/show_exceptions.rb" line 22 in rescue in call_with_rollbar
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rollbar-0.12.12/lib/rollbar/middleware/rails/show_exceptions.rb" line 19 in call_with_rollbar
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/actionpack-3.2.17/lib/action_dispatch/middleware/show_exceptions.rb" line 56 in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/railties-3.2.17/lib/rails/rack/logger.rb" line 32 in call_app
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/railties-3.2.17/lib/rails/rack/logger.rb" line 16 in block in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.17/lib/active_support/tagged_logging.rb" line 22 in tagged
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/railties-3.2.17/lib/rails/rack/logger.rb" line 16 in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/actionpack-3.2.17/lib/action_dispatch/middleware/request_id.rb" line 22 in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/methodoverride.rb" line 21 in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/runtime.rb" line 17 in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.17/lib/active_support/cache/strategy/local_cache.rb" line 72 in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/lock.rb" line 15 in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 136 in forward
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 143 in pass
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 155 in invalidate
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 71 in call!
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb" line 51 in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/railties-3.2.17/lib/rails/engine.rb" line 484 in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/railties-3.2.17/lib/rails/application.rb" line 231 in call
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/railties-3.2.17/lib/rails/railtie/configurable.rb" line 30 in method_missing
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 530 in process_client
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 604 in worker_loop
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 487 in spawn_missing_workers
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/unicorn-4.2.1/lib/unicorn/http_server.rb" line 137 in start
File "/path/to/app/shared/bundle/ruby/2.0.0/gems/unicorn-4.2.1/bin/unicorn" line 121 in <top (required)>
File "/path/to/app/shared/bundle/ruby/2.0.0/bin/unicorn" line 23 in load
File "/path/to/app/shared/bundle/ruby/2.0.0/bin/unicorn" line 23 in <main>

It would be great to get this resolved as I fear I'm missing errors my users are seeing because of this.

@brianr
Copy link
Member

brianr commented Mar 25, 2014

Thanks @fschwahn. I know @sbezboro spent a while trying to reproduce this but wasn't able. I don't suppose you have a reliable repro case?

@fschwahn
Copy link
Author

I just looked at the logs, and rollbar is trying to report an ArgumentError (invalid byte sequence in UTF-8)-exception, but fails because it cannot JSON.dump it. The error is in fact caused by some spambot trying to fill in my contact form, so it's not a big problem.

However, this should still be fixed as it could mask more serious errors behind internal rollbar errors.

Thanks for the quick reply!

@fschwahn
Copy link
Author

I investigated a little more, and the problem only occurs when using sidekiq as backend, because sidekiq dumps the payload as JSON before writing it to redis. To work around this issue the sidekiq-backend would have to sanitize the payload (e.g. using str.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') as suggested here: http://robots.thoughtbot.com/fight-back-utf-8-invalid-byte-sequences ). Here is a spec which replicates the issue:

context 'in face of malformed UTF-8' do
  let(:payload) { { 'foo' => "\255".force_encoding('UTF-8') } }
  it_behaves_like "a Rollbar processor"
end

@Exoth
Copy link

Exoth commented Apr 23, 2014

Having the same problem. It would be nice to have it fixed.

@malachaifrazier
Copy link

So...this is a Rollbar related issue? I've just seen this error reported while a third party firm was running security testing. Rails 3.2.17 and Ruby 2.0.0p451

@sbezboro
Copy link
Contributor

This should be fixed in this commit: 487acba

The above fix has been released to ruby gems as part of version 1.0.0. Thanks for the repro case @fschwahn!

@kroky
Copy link
Contributor

kroky commented Sep 17, 2014

@sbezboro, this issue is still happening for a payload hash with keys that are symbols improperly encoded in UTF-8. For example, run enforce_valid_utf8 or build_payload with the following data:

{:data => {"bad\x92 key".force_encoding('ASCII-8BIT').to_sym => "bad\x92 value"}}

This is actually happening for us with 1.0.0 release of rollbar as it seems rails ActionPack formats some hashes with symbols of ASCII-8BIT encoding depending on the incoming request. Let me know if you want to see a stacktrace.
May I suggest a fix in the enforce_valid_utf8 function that converts symbols to strings just before testing for a string and encoding it properly? Something like:

normalizer = Proc.new do |value|
  value = value.to_s if value.is_a?(Symbol)
  if value.is_a?(String)
    if value.respond_to? :encode
      value.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '')
    else
      ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', value)
    end
  else
    value
  end
end

I think converting symbols to strings here is OK as they are JSON-encoded as the end result and symbols become strings sooner or later but let me know if there will be side effects. Do you want me to submit a pull-request for this with proper tests?

@coryvirok
Copy link
Contributor

Hi Victor,

Thanks for the info. Please send over a PR and some tests. Otherwise, I'll add it to our backlog.

Thanks!

@brianr
Copy link
Member

brianr commented Oct 28, 2014

Closing this out -- #131 has been merged and released in 1.1.0. Thanks @kroky!

@brianr brianr closed this as completed Oct 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants