Description
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