Skip to content

Conversation

@mterhar
Copy link
Member

@mterhar mterhar commented Nov 6, 2025

Description

When a receiver uses the empty array for CompessionAlgorithm, it tells the middleware to pass any compressed body through to the receiver. This works fine for any body that has a Conent-Encoding header set, but when that header is missing, an empty string, or Identity, it will return a 400 response to the client without passing it along to the receiver.

This change bypasses the error when Content-Encoding is unset, empty, or Identity.

Link to tracking issue

Fixes #14131 and open-telemetry/opentelemetry-collector-contrib#44010

Testing

Added some test cases to ensure the missing content-encoding doesn't error out. The test fails with the original code and passes with the minimal change in the compression.go file.

Documentation

Allow unset content encoding to get through when the decompression middleware is disabled

fixes open-telemetry#14131
@mterhar mterhar requested a review from a team as a code owner November 6, 2025 06:29
@mterhar mterhar requested a review from TylerHelmuth November 6, 2025 06:29
@mterhar mterhar marked this pull request as draft November 6, 2025 06:29
@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.24%. Comparing base (6258454) to head (b3f109b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14132      +/-   ##
==========================================
- Coverage   92.25%   92.24%   -0.01%     
==========================================
  Files         658      658              
  Lines       41184    41186       +2     
==========================================
- Hits        37995    37994       -1     
- Misses       2183     2185       +2     
- Partials     1006     1007       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mterhar mterhar marked this pull request as ready for review November 6, 2025 20:12
@codeboten
Copy link
Contributor

@axw can you confirm that your comments have been addressed?

Copy link
Contributor

@axw axw left a comment

Choose a reason for hiding this comment

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

Looks good, just a few minor things.

Comment on lines +281 to +283
if len(d.decoders) == 0 {
return nil, nil // Signal: don't replace r.Body
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just not add the decompressor in the first place, if the configured list is empty?
(Happy for this to be done in a followup.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried to do that, but it was skipping decompression too much sometimes. I am happy to take another stab at it but I’d like to make it a follow-up.

mterhar and others added 2 commits November 16, 2025 21:56
Co-authored-by: Andrew Wilkins <[email protected]>
Co-authored-by: Andrew Wilkins <[email protected]>
Copy link
Contributor

@axw axw left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@codeboten codeboten added this pull request to the merge queue Nov 17, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 17, 2025
@codeboten codeboten enabled auto-merge November 17, 2025 17:14
@codeboten codeboten added this pull request to the merge queue Nov 17, 2025
Merged via the queue into open-telemetry:main with commit 5adc149 Nov 17, 2025
60 checks passed
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.

When overriding httpConfig.CompressionAlgorithms, it rejects empty Content-Encoding

4 participants