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

[otlphttpexporter] partial success handlers attempt to unmarshal a nil value when response content-length is 0 #9666

Open
senojj opened this issue Feb 29, 2024 · 0 comments
Labels
bug Something isn't working exporter/otlphttp

Comments

@senojj
Copy link
Contributor

senojj commented Feb 29, 2024

Describe the bug
In the otlphttpexporter exporter's otlp.go file, when the export HTTP response body is read using the function readResponseBody a value of nil, nil will be returned when resp.ContentLength is 0.

Later, that nil value is passed to one of the partial success handlers (e.g. tracesPartialSuccessHandler). No check is made for a nil value in the protoBytes argument, so an attempt to unmarshal the nil value is possible.

Edit: This is only the case when the content type is specified as "application/json". This does not apply when the content type is specified as "application/x-protobuf".

Steps to reproduce
Provide an empty in response to an export. Ensure that an expected Content-Type response header field is given, such as "application/json" or "application/x-protobuf".

What did you expect to see?
An empty response body should not result in an error. It is perfectly valid for the logic to continue without processing a response body.

What did you see instead?
An error is raised and the successful request is potentially retried after a backoff duration.

What version did you use?
fb912b9

What config did you use?
Any configuration using otlphttpexporter as an exporter.

Environment
Any environment

@senojj senojj added the bug Something isn't working label Feb 29, 2024
dmitryax pushed a commit that referenced this issue Mar 21, 2024
…response body is empty (#9667)

**Description:**
Fixing a bug - When exporting using the otlphttpexporter, after
receiving a successful HTTP response, when the response body's content
length is 0 and the content type is specified as either
"application/json" or "application/x-protobuf", an attempt will be made
to unmarshal a nil value within any of the partial success response
handler functions. This results in an error, and a potential resend of
the original export request.

To fix this scenario, a check was added to the
`tracesPartialSuccessHandler`, `metricsPartialSuccessHandler`, and
`logsPartialSuccessHandler` functions for a `nil` value in the
`protoBytes` argument. When `nil`, the function will return with a `nil`
value, indicating the absence of any error.

**Link to tracking Issue:** #9666
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working exporter/otlphttp
Projects
None yet
Development

No branches or pull requests

2 participants