Skip to content

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

Open
@senojj

Description

@senojj

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions