Sudden error running newrelic python agent - 'WebTransaction' has no attribute 'unicode_error_reported'
See original GitHub issueHonestly 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:
- Created a year ago
- Reactions:1
- Comments:5 (4 by maintainers)
@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.
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.