Skip to content

[receiver/loki] fix Content-Type parsing#41195

Merged
songy23 merged 14 commits into
open-telemetry:mainfrom
Abuelodelanada:fix-loki-receiver-content-type
Jul 11, 2025
Merged

[receiver/loki] fix Content-Type parsing#41195
songy23 merged 14 commits into
open-telemetry:mainfrom
Abuelodelanada:fix-loki-receiver-content-type

Conversation

@Abuelodelanada

Copy link
Copy Markdown
Contributor

Description

This PR correctly parses the Content-Type of a request in newLokiReceiver the same way it is done in push.go

Link to tracking issue

Fixes: #41192

Testing

Run this test

$ go test -v -run TestNewLokiReceiver_SupportedContentTypeWithCharset
=== RUN   TestNewLokiReceiver_SupportedContentTypeWithCharset
--- PASS: TestNewLokiReceiver_SupportedContentTypeWithCharset (0.00s)
PASS
ok      github.com/open-telemetry/opentelemetry-collector-contrib/receiver/lokireceiver 0.005s

@Abuelodelanada Abuelodelanada requested a review from a team as a code owner July 8, 2025 20:57
@Abuelodelanada Abuelodelanada requested a review from ArthurSens July 8, 2025 20:57
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 8, 2025

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@Abuelodelanada

Copy link
Copy Markdown
Contributor Author

Hi Irina @mar4uk!

The error that this PR fixes prevents clients to send log using valid json because of an error in the Content-Type parsing.

Please, let me know if I can help!

@andrzej-stencel andrzej-stencel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Abuelodelanada thanks for this change; please add a changelog entry.

@andrzej-stencel andrzej-stencel changed the title fix Content-Type parsing [receiver/loki] fix Content-Type parsing Jul 10, 2025
@Abuelodelanada

Copy link
Copy Markdown
Contributor Author

Hello @andrzej-stencel,

Thanks for your review! Changelog entry added!

@mar4uk

mar4uk commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

Hey! Thank you for the fix 👍 LGTM!

Comment thread .chloggen/fix-loki-receiver-content-type.yaml Outdated
Comment thread .chloggen/fix-loki-receiver-content-type.yaml Outdated
@andrzej-stencel

Copy link
Copy Markdown
Member

@Abuelodelanada please run make gci and make lint in the receiver/loki directory to fix formatting and check for linting errors.

Abuelodelanada and others added 4 commits July 11, 2025 09:35
@Abuelodelanada

Copy link
Copy Markdown
Contributor Author

Hey @andrzej-stencel @mar4uk

Comments addressed. Linting fixed!

@songy23 songy23 merged commit c05c683 into open-telemetry:main Jul 11, 2025
177 checks passed
@github-actions github-actions Bot added this to the next release milestone Jul 11, 2025
Dylan-M pushed a commit to Dylan-M/opentelemetry-collector-contrib that referenced this pull request Aug 5, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

This PR correctly parses the `Content-Type` of a request in
`newLokiReceiver` the same way it is done in
[`push.go`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/lokireceiver/internal/push.go#L49)


<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes:
open-telemetry#41192

<!--Describe what testing was performed and which tests were added.-->
#### Testing

Run this test

```shell
$ go test -v -run TestNewLokiReceiver_SupportedContentTypeWithCharset
=== RUN   TestNewLokiReceiver_SupportedContentTypeWithCharset
--- PASS: TestNewLokiReceiver_SupportedContentTypeWithCharset (0.00s)
PASS
ok      github.com/open-telemetry/opentelemetry-collector-contrib/receiver/lokireceiver 0.005s

```

---------

Co-authored-by: Andrzej Stencel <andrzej.stencel@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[receiver/lokireceiver]: Rejected logs when Content-Type: application/json; charset=utf-8

4 participants