Skip to content

quote_from_bytes() expected bytes #1626

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

Closed
lehmat opened this issue Sep 18, 2022 · 5 comments · Fixed by #1630
Closed

quote_from_bytes() expected bytes #1626

lehmat opened this issue Sep 18, 2022 · 5 comments · Fixed by #1630
Assignees

Comments

@lehmat
Copy link

lehmat commented Sep 18, 2022

How do you use Sentry?

Self-hosted/on-premise

Version

1.9.8

Steps to Reproduce

None, all API requests fail to this

Expected Result

It is OK to log the error about sentry-tracing not being able to do its magic, but it should not make the full application error out

Actual Result

Traceback (most recent call last):
  File "/var/task/botocore/httpsession.py", line 448, in send
    urllib_response = conn.urlopen(
  File "/var/task/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/var/task/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/var/task/urllib3/connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/python/lib/python3.9/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/var/task/botocore/awsrequest.py", line 94, in _send_request
    rval = super()._send_request(
  File "/usr/local/python/lib/python3.9/http/client.py", line 1296, in _send_request
    self.putrequest(method, url, **skips)
  File "/var/task/urllib3/connection.py", line 219, in putrequest
    return _HTTPConnection.putrequest(self, method, url, *args, **kwargs)
  File "/var/task/sentry_sdk/integrations/stdlib.py", line 88, in putrequest
    for key, value in hub.iter_trace_propagation_headers(span):
  File "/var/task/sentry_sdk/hub.py", line 717, in iter_trace_propagation_headers
    for header in span.iter_headers():
  File "/var/task/sentry_sdk/tracing.py", line 322, in iter_headers
    baggage = self.containing_transaction.get_baggage().serialize()
  File "/var/task/sentry_sdk/tracing_utils.py", line 541, in serialize
    item = Baggage.SENTRY_PREFIX + quote(key) + "=" + quote(val)
  File "/usr/local/python/lib/python3.9/urllib/parse.py", line 871, in quote
    return quote_from_bytes(string, safe)
  File "/usr/local/python/lib/python3.9/urllib/parse.py", line 896, in quote_from_bytes
    raise TypeError("quote_from_bytes() expected bytes")
@lehmat
Copy link
Author

lehmat commented Sep 18, 2022

This issue was first introduced when I upgraded from 1.9.5 -> 1.9.8 and whole production went down. I would like to see some try: except since this is a monitoring tool that should not cause whole production to go down.

@sl0thentr0py
Copy link
Member

@lehmat thx for reporting. Can you give me your sentry init options? Just trying to see why this could happen in the first place.

@lehmat
Copy link
Author

lehmat commented Sep 19, 2022

sentry_sdk.init(
    dsn=self.app.config["SENTRY_URL"],
    integrations=[
        FlaskIntegration(transaction_style="url"),
    ],
    release=self.app.config["SENTRY_RELEASE"],
    send_default_pii=True,
    traces_sample_rate=0.5,
)

And we are running on-premise sentry with release version: Sentry 22.9.0.dev0

@sl0thentr0py
Copy link
Member

is your SENTRY_RELEASE by any chance an integer?

@lehmat
Copy link
Author

lehmat commented Sep 19, 2022

It is defaulted to integer: 1 so it surely might be the root cause

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

Successfully merging a pull request may close this issue.

3 participants