-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Requests to Elasticsearch with two traceparent
headers should yield 400 Bad Request
#107338
Comments
The spec describes how to handle the case where no header is received, and when a (singular) header is received, but not how to deal with multiple such headers, so I think it's legitimate to consider such requests malformed and reject them straight away. We generally prefer to be as strict as possible about matters like this. I dread to think how hard it would be to debug this if we made things more lenient. That said, we should be returning a |
Pinging @elastic/es-distributed (Team:Distributed) |
traceparent
headers fail, and shouldn'ttraceparent
headers should yield 400 Bad Request
Today if the HTTP header validation throws an exception (rather than calling `listener.onFailure()`) then we treat this as a server-side error, record it in the logs, and close the connection abruptly without sending a response. In practice such an exception is more likely a client-side error, so with this commit we catch it and marshal it back to the client instead. Closes elastic#107338
Today if the HTTP header validation throws an exception (rather than calling `listener.onFailure()`) then we treat this as a server-side error, record it in the logs, and close the connection abruptly without sending a response. In practice such an exception is more likely a client-side error, so with this commit we catch it and marshal it back to the client instead. Closes #107338
Today if the HTTP header validation throws an exception (rather than calling `listener.onFailure()`) then we treat this as a server-side error, record it in the logs, and close the connection abruptly without sending a response. In practice such an exception is more likely a client-side error, so with this commit we catch it and marshal it back to the client instead. Closes elastic#107338
Today if the HTTP header validation throws an exception (rather than calling `listener.onFailure()`) then we treat this as a server-side error, record it in the logs, and close the connection abruptly without sending a response. In practice such an exception is more likely a client-side error, so with this commit we catch it and marshal it back to the client instead. Closes #107338
Elasticsearch Version
8.12.2
Installed Plugins
No response
Java Version
bundled
OS Version
Darwin (though this happens on ESS, and an Elasticsearch docker image)
Problem Description
Requests to Elasticsearch with two
traceparent
headers fail. I don't think they should, but I'm happy to be proven wrong.We received an issue from a user that requests to Elasticsearch from the JS client were failing when their Node.js app was instrumented with the Elastic APM Node.js agent. It turns out that the user was using two separate APM agents on the app. With both APM agents running, HTTP requests to Elasticsearch would have two
traceparent
headers.This section of the W3C trace-context spec (https://w3c.github.io/trace-context/#a-traceparent-is-received) says:
My read of that spec is that an invalid traceparent is received (I'd classify multiple traceparent headers as invalid, though the spec doesn't specifically say that), then the
traceparent
andtracestate
headers should be ignored.Steps to Reproduce
For example:
A log message from a
v8.13.0-SNAPSHOT
test cluster of mine for a request list this:Logs (if relevant)
The text was updated successfully, but these errors were encountered: