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

Distributor: do not propagate errors with non-utf8 characters #10236

Merged
merged 4 commits into from
Dec 15, 2024

Conversation

duricanikolic
Copy link
Contributor

What this PR does

This PR prevents distributor.OTLPHandler and distributor.Handler from propagating errors containing non-utf8 characters.
The presence of non-utf8 characters in Mimir errors might break some crucial parts of distributor's logic. For example, if httpgrpc.HTTPServer.Handle() returns a httpgprc.Error containing a non-utf8 character, this error will not be propagated to httpgrpc.HTTPClient as a htttpgrpc.Error, but as a generic error, which might break some of Mimir internal logic.
This is because golang's proto.Marshal(), which is used by gRPC internally, fails when it marshals the httpgrpc.Error containing non-utf8 character produced by httpgrpc.HTTPServer.Handle(), making the resulting error lose some important properties.

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@duricanikolic duricanikolic self-assigned this Dec 13, 2024
{Key: "Content-Type", Values: []string{"application/json"}},
},
Url: "/otlp",
Body: []byte("\n\xf6\x16\n\xd3\x02\n\x1d\n\x11container.runtime\x12\x08\n\x06docker\n'\n\x12container.h"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure that the test is correct, but it would be easier to read and understand it if it had a comment explaining which character is not valid UTF-8 and with which other character we expect it to be replaced.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a comment explaining which characters are non-UTF8, and what should they be replaced with. Thank you.

Copy link
Contributor

@replay replay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

Signed-off-by: Yuri Nikolic <[email protected]>
@duricanikolic duricanikolic marked this pull request as ready for review December 15, 2024 20:44
@duricanikolic duricanikolic requested a review from a team as a code owner December 15, 2024 20:44
@duricanikolic duricanikolic merged commit 3410e68 into main Dec 15, 2024
29 checks passed
@duricanikolic duricanikolic deleted the yuri/otel-errors branch December 15, 2024 20:45
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

Successfully merging this pull request may close these issues.

2 participants