question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError json.encoder in default instead of real error, using sentry-sdk python

See original GitHub issue

Environment

SaaS (https://sentry.io/)

Version

No response

Steps to Reproduce

  1. have an URL triggering an error that contains special chars, for example an “!”
  2. in sentry, I’ll get a strange TypeError json.encoder in default
  3. with an epic long stacktrace, that goes through all my django middlewares and more
  4. using gunicorn. not sure if on my side something is configured wrong? as far as I can see, I use a very basic default configuration

python sentry-sdk: 1.4.2

    sentry_sdk.init(
        dsn=SENTRY_DSN,
        release=VERSION,
        integrations=[DjangoIntegration()],
    )

Expected Result

Report AttributeError 'NoneType' object has no attribute 'url_name' as is the orginal error in this case.

Actual Result

TypeError json.encoder in default

the (probably) payload, that is wanted to be json serialized:

{
environment: 'production', 
public_key: 'blbalbalbablaFOOOOO, 
release: b'0.0.1-178-g889a3c7', 
trace_id: 'the-trace-id', 
transaction: '/medien/Pressedossier_PENG!_PALAST.pdf'
}


Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ibushongcommented, Nov 17, 2021

@benzkji, I had the same issue, with this same apparent cause. Your release argument to init() is of type bytes. You should add decode() after it to convert it to a string. That resolved the issue for me. Though it is interesting that this only happened as of v1.4.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError json.encoder in default instead of real error ... - GitHub
have an URL triggering an error that contains special chars, for example an "!" in sentry, I'll get a strange TypeError json.encoder in...
Read more >
Custom JSON Encoder raises "Object not JSON serializable ...
I am trying to create a custom JSON Encoder for one of my classes. I have created a simplified version to try the...
Read more >
Issue 24313: json fails to serialise numpy.int64 - Python tracker
I use json 2.0.9 and numpy 1.9.2 with both versions of Python. ... 174 175 def encode(self, o): TypeError: 1 is not JSON...
Read more >
1657425 - sentry errors while running `mach python-test`
I ran mach python-test python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py from my objdir, and got output that looked like:
Read more >
Logging - Sentry Documentation
event_level (default ERROR ): The Sentry Python SDK will report log records with a level higher than or equal to event_level as events....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found