Skip to content

fix: bound compressor minContentLength before narrowing to uint32 - #9852

Open
dxbjavid wants to merge 1 commit into
envoyproxy:mainfrom
dxbjavid:compression-mincontentlength-overflow
Open

dxbjavid wants to merge 1 commit into
envoyproxy:mainfrom
dxbjavid:compression-mincontentlength-overflow

Conversation

@dxbjavid

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

minContentLength on a compressor is a resource.Quantity, and its CRD pattern allows suffixes up to Ei, so the API server accepts values well above 4 GiB. buildCompression cast the parsed int64 straight to a uint32, which quietly wraps: 4Gi became 0, so Envoy compressed every response rather than only large ones, the opposite of what was configured (4Gi+30 lands on 30, and so on). This routes the value through the existing int64ToUint32 bounds check, the same helper the other numeric fields in this file already use, and surfaces a policy error for out-of-range values instead of silently truncating. The deprecated spec.compression[] path had the same cast and gets the same fix.

Which issue(s) this PR fixes:
Fixes #


PR Checklist

  • Authorship & ownership: Coding agents / AI assistants are welcome, but I have reviewed every change, understand how and why it works, can explain and maintain it, and take full responsibility for this PR. I have not submitted generated output I do not understand.
  • DCO: All commits are signed off (git commit -s). See DCO: Sign your work.
  • API agreed first: N/A: no API changes.
  • Required checks pass: make lint and the unit tests for the touched package pass locally.
  • Tests added/updated: added boundary and overflow cases to TestBuildCompression.
  • Docs: N/A: no user-facing docs change.
  • Release notes: added release-notes/current/bug_fixes/9852-compression-mincontentlength-overflow.md.
  • Generated files committed: N/A: no API/helm/module changes.
  • Scope & compatibility: scoped to the compression translation, behaviour for valid inputs is unchanged.
  • Codex review: Requested a Codex review and addressed all of its comments.
  • Copilot review: Requested a Copilot review and addressed all of its comments.

@dxbjavid
dxbjavid requested a review from a team as a code owner August 26, 2026 07:48
@netlify

netlify Bot commented Aug 26, 2026

Copy link
Copy Markdown

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit d846148
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a954967c3312600086409ca
😎 Deploy Preview https://deploy-preview-9852--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.60870% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.27%. Comparing base (3b80726) to head (d846148).

Files with missing lines Patch % Lines
internal/gatewayapi/backendtrafficpolicy.go 82.60% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9852      +/-   ##
==========================================
- Coverage   81.29%   81.27%   -0.02%     
==========================================
  Files         263      263              
  Lines       40859    40870      +11     
==========================================
+ Hits        33216    33218       +2     
- Misses       7643     7652       +9     

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arkodg arkodg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM thanks

@arkodg
arkodg requested review from a team August 31, 2026 06:12
@arkodg arkodg added this to the v1.10.0-rc.1 Release milestone Aug 31, 2026
Signed-off-by: Javid Khan <dxbjavid@gmail.com>
@zirain
zirain force-pushed the compression-mincontentlength-overflow branch from da6041d to d846148 Compare August 31, 2026 09:29
return result, nil
}

// minContentLengthToUint32 converts the CRD quantity to the uint32 Envoy expects. The

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment seems to be documenting the previously broken behavior as a justification for its existence. Maybe it could be tightened up.

// minContentLengthToUint32 converts the CRD quantity to the uint32 Envoy expects. 
// It rejects out-of-range values.

@zirain

zirain commented Sep 15, 2026

Copy link
Copy Markdown
Member

/retest

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.

4 participants