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.

Sudden error running newrelic python agent - 'WebTransaction' has no attribute 'unicode_error_reported'

See original GitHub issue

Honestly I don’t think this is a bug report. But couldn’t club in other category. So apologies!!!

Description NOTE: # ( Describe the problem you’re encountering. ) [TIP]: # ( Do NOT share sensitive information, whether personal, proprietary, or otherwise! )

We’ve been running pretty old version of newrelic agents in our python and node servers. But they have been running seamlessly all the while. But the python newrelic agent started throwing error today out of nowhere. I wasn’t able to detect what caused it. Moreover this happened only in our stage environments, luckily. So more I wondered why not production env. I checked diff between two, nothing. No change done to stage or prod envs.

The error was obvious as it’s a class variable typo in the version. So upgrading the newrelic agent version fixed it. But why the error was encountered in the first place is what am trying to understand.

Our servers run on Heroku using gunicorn==18.0.

And following is the log trace

01 Sep 2022 06:46:53.570128 <190>1 2022-09-01T01:16:52.946562+00:00 app web.1 - - Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.7/site-packages/newrelic-2.54.0.41/newrelic/api/web_transaction.py", line 550, in browser_timing_header
    header.encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode character '\xa9' in position 36599: ordinal not in range(128)Exception
01 Sep 2022 06:46:53.570128 <190>1 2022-09-01T01:16:52.946567+00:00 app web.1 - - Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/base.py", line 131, in get_response
    response = middleware_method(request, response)
  File "/app/.heroku/python/lib/python3.7/site-packages/newrelic-2.54.0.41/newrelic/hooks/framework_django.py", line 331, in wrapper
    return wrapped(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/newrelic-2.54.0.41/newrelic/hooks/framework_django.py", line 130, in browser_timing_middleware
    header = transaction.browser_timing_header()
  File "/app/.heroku/python/lib/python3.7/site-packages/newrelic-2.54.0.41/newrelic/api/web_transaction.py", line 553, in browser_timing_header
    if not WebTransaction.unicode_error_reported:
AttributeError: type object 'WebTransaction' has no attribute 'unicode_error_reported'Exception

The header above code is trying to encode is a script tag (very large JS code and thus clipped) and its beginning is following:

'<script type="text/javascript">(window.NREUM||(NREUM={})).init={ajax:{deny_list:["bam.nr-data.net"]}};(window.NREUM||(NREUM={})).loader_config={licenseKey:"XXXXXXXXX",applicationID:"XXXXXXXX"};/*! For license information please see nr-loader-rum-1218.min.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?defin'

IMO this is an unusual header. But the code’s use seems to enable tracking in JS client (either browser or NodeJS). If we were getting this header earlier, we would had got this error earlier or in prod env. So most likely we have started to get this header somehow. I can’t understand how. This obv is happening today only.

Also, when I restarted the servers, the site would load but then any other web request gave Server errors. API requests ran without any error.

Expected Behavior NOTE: # ( Tell us what you expected to happen. )

Ascii encode error wouldn’t trigger and thus the workflow never entered the incorrect exception handler code

Steps to Reproduce NOTE: # ( Please be as specific as possible. ) [TIP]: # ( Link a sample application that demonstrates the issue. )

I was able to reproduce this error in local using the new relic instance connectivity. Obv after I upgrade the python newrelic agent version to 7.16.0.178, the error goes away as it silently ignores the header

Your Environment [TIP]: # ( Include as many relevant details about your environment as possible including the running version of New Relic software and any relevant configurations. )

Stage (and prod) environment - Ubuntu 18 (https://devcenter.heroku.com/articles/heroku-18-stack), Python - 3.7.10, Django - 1.11.29 Local environment - macOS Monterey, Version - 12.5, Python - 3.8.9, Django - 1.11.29 newrelic python agent version - 2.54.0.41

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
TimPansinocommented, Sep 1, 2022

@anshukch Thanks for the report, we’ve gotten other reports internally now so it’s definitely affecting other customers besides you. The team is working on it as we speak, I’ll post back here if they don’t when everything is resolved.

1reaction
TimPansinocommented, Sep 1, 2022

The issue has been remediated by the browser team, after a restart agents should receive a version of the browser agent that doesn’t cause any issues.

Older versions of the agent should be back to working normally and don’t require setting browser_monitoring.enabled = False anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python agent not sending error - New Relic Explorers Hub
We saw a UnicodeEncodeError in Sentry (which we also have running in that ... to the “AttributeError: 'NoneType' object has no attribute ......
Read more >
[Python] Seeing these errors - Agents - New Relic Explorers Hub
I am sorry that you are experiencing this error. I would first recommend updating your Python agent and seeing if this error still...
Read more >
[Python] Bug in Python agent - New Relic Explorers Hub
It appears that there's a code problem in the Python agent. ... Got 'DatabaseTrace' object has no attribute 'sql_format' error.
Read more >
Python agent attributes | New Relic Documentation
Python agent web transaction attributes. The following lists the attributes that can be configured in the Python agent for web transactions.
Read more >
[Python] module 'newrelic.agent' has no attribute ...
Hi, I am getting the following error when attempting to log through the agent in a Python Lambda on AWS: module 'newrelic.agent' has...
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