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

Transaction sending failed: "\xD9" from ASCII-8BIT to UTF-8 #1992

Closed
thibaultlavoisey opened this issue Feb 2, 2023 · 3 comments · Fixed by #1997
Closed

Transaction sending failed: "\xD9" from ASCII-8BIT to UTF-8 #1992

thibaultlavoisey opened this issue Feb 2, 2023 · 3 comments · Fixed by #1997
Assignees

Comments

@thibaultlavoisey
Copy link

thibaultlavoisey commented Feb 2, 2023

Issue Description

(Similar to #1911)

Hello,

I got the error Transaction sending failed: "\xD9" from ASCII-8BIT to UTF-8 that's raised from this method:

def initialize(headers, payload)
@headers = headers
@payload = payload
end

Here is the log:

Screenshot 2023-02-02 at 22 40 55

We're using MessagePack to serialize data before storing them into Redis. The encoding of the string returned by MessagePack is ASCII_8BIT. This string is captured in a Sentry span description, and the serialization into JSON fails due to the invalid encoding:

Screenshot 2023-02-02 at 22 54 31

We try to fix this issue using the before_send hook, but unfortunately we've not been able to find spans in the event object.

We finally fixed this issue by monkey patching the set_description method of the Sentry::Span class:

Screenshot 2023-02-02 at 23 14 30

Is this a known issue that should be fixed in Sentry SDK directly? If not, is there a way to deal with non UTF-8 string using the before_send hook?

Reproduction Steps

In a Rails project with Sentry and MessagePack installed:

Sentry.capture_message(MessagePack.pack('test message'))

Expected Behavior

Event is sent to Sentry.

Actual Behavior

Event isn't sent to Sentry.

Ruby Version

2.7.4

SDK Version

5.7.0

Integration and Its Version

rails (6.0.5.1), sentry-rails (5.7.0), sidekiq (5.2.2), sentry-sidekiq (5.7.0)

Sentry Config

# frozen_string_literal: true

Sentry.init do |config|
  config.dsn = ENV['SENTRY_DSN']
  config.breadcrumbs_logger = [:active_support_logger, :http_logger]

  # Tracing Options
  config.traces_sample_rate = 1.0
end
@sl0thentr0py
Copy link
Member

So re:

Sentry.capture_message(MessagePack.pack('test message'))

I'm not sure that makes sense to support, wdyt @st0012 .

imo this should just be fixed on the Redis integration so that the description only contains well formatted strings and not binary stuff.

@sl0thentr0py
Copy link
Member

@thibaultlavoisey if I gather correctly, your redis key is MessagePack'd?

@thibaultlavoisey
Copy link
Author

@sl0thentr0py Yes, correct! So the key is displayed in the Sentry span description, and serialization to JSON fails due to non UTF-8 characters (the ones from the key that has been MessagePack'd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants