Skip to content
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

Tomcat exception being tagged as an error incorrectly #5108

Closed
Jarda8 opened this issue Apr 24, 2023 · 3 comments
Closed

Tomcat exception being tagged as an error incorrectly #5108

Jarda8 opened this issue Apr 24, 2023 · 3 comments
Assignees

Comments

@Jarda8
Copy link

Jarda8 commented Apr 24, 2023

Hi team. We use the DD agent together with Spring Boot 3 REST application. We use the trace.servlet.request.errors metric to monitor errors. From what I read and expect, it should not tag 4XX responses as an error by default and in majority of cases it really does not. However, when we get a request with some invalid characters in the URL (a client error we do not care about), it is marked as an error, even though the response has 400 status. There is an exception thrown in Tomcat visible in the DD trace, but it is caught immediately and handled still in Tomcat. It does not even touches our code, as the validation and response creation happens within Tomcat. An example of the exception:

java.lang.IllegalArgumentException: Invalid character found in the request target [/hierarchy-entities/custom-fields-values?file:\ ]. The valid characters are defined in RFC 7230 and RFC 3986
	at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:482)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:263)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:894)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1741)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:1589)

It seems like a problem within the DD agent, tagging this as an error incorrectly. Or is it an expected behaviour for some reason?

@amarziali amarziali self-assigned this Apr 25, 2023
@amarziali
Copy link
Collaborator

Actually the error is wrapped by tomcat in the response hence then extracted by the DD agent and reported. Older version of tomcat are accepting backslashes hence the error is not thrown in the same case. We are working to understand if there is a reasonable fix to do without loosing information.
On the same time you can workaround the issue by configuring tomcat to accept backslashes.
The sys props are:

  • -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
  • -Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true

@amarziali
Copy link
Collaborator

should be fixed by #5128

@Jarda8
Copy link
Author

Jarda8 commented May 2, 2023

Thank you for the insight. And the fix.

@Jarda8 Jarda8 closed this as completed May 2, 2023
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

No branches or pull requests

2 participants