fix(opentelemetry source): return 4xx instead of 500 for rejected HTTP requests - #26509
Open
Andrew-Hinson wants to merge 2 commits into
Open
Andrew-Hinson wants to merge 2 commits into
Andrew-Hinson wants to merge 2 commits into
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Comment on lines
464
to
473
| } else if err.find::<warp::reject::MethodNotAllowed>().is_some() { | ||
| ( | ||
| "Method not allowed; this endpoint requires `POST`.".into(), | ||
| StatusCode::METHOD_NOT_ALLOWED, | ||
| ) | ||
| } else if err.is_not_found() { | ||
| ("Not found.".into(), StatusCode::NOT_FOUND) | ||
| } else { | ||
| (format!("{err:?}"), StatusCode::INTERNAL_SERVER_ERROR) | ||
| }; |
Member
There was a problem hiding this comment.
Could we use some code similar to this to implement the fall-through cases here instead of handling one-by-one?
Author
There was a problem hiding this comment.
@thomasqueirozb Done, the one trade off is that those responses now have plain text bodies instead of protobuf though.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
opentelemetrysource's OTLP/HTTP rejection handler returned500 Internal Server Errorfor every warp rejection that wasn't an
ErrorMessage, with the rejection'sDebugoutput(e.g.
Rejection(InvalidHeader { name: "content-type" })) as the message. So a clientsending the wrong content type got what looked like a server crash.
This PR maps those rejections to the right client errors:
Content-Typeis now415 Unsupported Media TypePOSTmethod now returns405 Method Not Allowed404 Not FoundAnything else still returns 500. This is the minimal fix suggested in the issue; accepting
OTLP/HTTP JSON would be a separate feature.
One thing I left out of scope: a malformed
content-encodingheader still returns 500.Most of this change was written with Claude Opus 5.5; I reviewed and tested it.
References
Closes: #26456
Vector configuration
How did you test this PR?
Added
http_rejections_return_client_error_status_codes, which fails on master and passeswith this change:
All OpenTelemetry source tests pass (Rust 1.96.1, Arch Linux).
I also ran a local build with the config above and sent requests with
curl:Content-Type: application/jsonContent-Type/v1/logs/v1/nopeapplication/x-protobufDoes this PR include user facing changes?
changelog.d/26456_opentelemetry_http_rejection_status.fix.md