-
Notifications
You must be signed in to change notification settings - Fork 600
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
browser_monitoring throws exception on non string HTTP header Content-Type #2462
Comments
Hi @miry, Thanks for letting us know about this issue. It looks like you have a symbol ( Would you please let us know which part of your app / stack is responsible for setting that We currently expect a) that all header hashes we're working with have been built by Rack and b) that they adhere to the Rack spec that requires header hash keys and values to be strings. The latest version of Rack still provides We are curious if there is something in Rails v7 or Rack v3 that is using symbols that we weren't previously aware of, or if your application is using something other than Rack or using some custom middleware to touch the headers. If you happen to know how the symbol is being set as a hash value, that information would help us in coming up with a fix. Please let us know your best understanding of how the value is getting set when you get a chance. Thanks! |
I have the same expectations; headers are supposed to consist only of strings. The challenge for me is that I've been unable to reproduce the problem on my development environment, but it does occur in staging and production (and don't have access to staging and production). I would try to simulate the problem though. However, resolving the header issue is not the primary focus here |
Thanks, @miry. As part of resolving this one we'll be sure to harden the various touchpoints defined in |
A bit more of the context: Ruby runs with +YJIT mode. The application runs behind Cloudflare on Heroku. I tried to reproduce localy, but did not help. UPDATE: If I understand correctly the Middleware calls, after the next call,
In this case we use https://github.com/ruby-grape/grape. I would expect clients would make such mistakes :( UPDATE: Now I found the reason of such sily mistake. As I expected in the Grape code someone wrote: desc "Return a list of comments for the specific product"
get do
# ...
content_type :json
# ...
end MY SUMMARY:
|
These changes introduce hardening to the logic that determines whether or not to inject the browser agent script tag. In particular, the following 2 issues have been addressed: 1. If either `#traced_call` or `#should_instrument?` encounter any exceptions, these exceptions should be handled and logged without impacting the observed web application. 2. Allow a response headers hash to use symbols for values. Closes #2462
Hi @miry. The PR has been merged and the next version of the agent that gets released with accept symbol based values and better handle exceptions. Thanks for bringing this one to our attention! |
Description
Found two problems in case the request HTTP header ContentType is Symbol,
then newrelic just produces exception:
Expected Behavior
Newrelic should catch all exceptions with invalid headers and does not throw exception.
Troubleshooting or NR Diag results
Provide any other relevant log data.
TIP: Scrub logs and diagnostic information for sensitive information
The line:
newrelic-ruby-agent/lib/new_relic/rack/browser_monitoring.rb
Line 103 in 414ddad
Backtrace
Steps to Reproduce
Set in test header['Content-Type'] = :"text/html"
Your Environment
Rails 7.0
Ruby 3.3
The text was updated successfully, but these errors were encountered: