Skip to content

fix(proxy): strip encoded loop headers#261

Merged
jon-devlapaz merged 1 commit into
mainfrom
feat/loop-proxy-header-fix
Jun 16, 2026
Merged

fix(proxy): strip encoded loop headers#261
jon-devlapaz merged 1 commit into
mainfrom
feat/loop-proxy-header-fix

Conversation

@jon-devlapaz

Copy link
Copy Markdown
Owner

Context & Intent

  • Salvages the one loadbearing proxy slice from codex/loop-proxy-encoding-rescue.
  • The current proxy forwards Accept-Encoding and can return stale Content-Encoding after reading/decompressing upstream content, which can confuse browser clients.

Implementation Details

  • Drops request Accept-Encoding before proxying to the loop backend.
  • Drops response Content-Encoding before returning proxied content.
  • Adds focused loop backend proxy coverage.

MVP / Deployment Risk Check

  • Does this logic rely on local behavior that might fail in Vercel serverless? No.
  • Are there SSRF or error leakage risks in new external calls? No new external call surface.
  • If dealing with ingestion, is the manual fallback preserved? Not applicable.

UX Framework Alignment (For UI/Drill changes)

  • Does this strictly enforce Generation Before Recognition? Not learner-surface behavior.
  • Does the graph still tell the truth? Not graph behavior.
  • Is the active cognitive target explicitly clear to the user? Not UI behavior.

Verification:

  • .venv/bin/pytest tests/test_loop_backend_proxy.py -q

Preserve the local loop proxy fix before returning the checkout to main.

The proxy already removes hop-by-hop headers; encoded upstream bodies also need matching encoding headers stripped so Starlette does not advertise gzip for decoded fixture bodies.
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
learn-ops-tamagachi Ready Ready Preview, Comment Jun 16, 2026 10:46pm

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9004ae44-12f3-412e-975b-37923efdad99

📥 Commits

Reviewing files that changed from the base of the PR and between 2bedab8 and f4fc6c8.

📒 Files selected for processing (2)
  • loop_backend_proxy.py
  • tests/test_loop_backend_proxy.py

📝 Walkthrough

Summary by CodeRabbit

Bug Fixes

  • Enhanced backend proxy to properly filter encoding headers in both client requests and upstream responses, preventing unnecessary forwarding
  • Reduces communication overhead and improves overall efficiency between clients and backend services

Walkthrough

Separate _REQUEST_HEADER_DENYLIST and _RESPONSE_HEADER_DENYLIST constants are added to loop_backend_proxy.py, extending the existing hop-by-hop set with accept-encoding and content-encoding respectively. _forward_headers and _response_headers are updated to use these new constants. Tests are extended to validate both filtering rules.

Changes

Loop Backend Proxy Header Denylist

Layer / File(s) Summary
Denylist constants and header filtering
loop_backend_proxy.py
Defines _REQUEST_HEADER_DENYLIST = _HOP_BY_HOP | {"accept-encoding"} and _RESPONSE_HEADER_DENYLIST = _HOP_BY_HOP | {"content-encoding"}, then switches _forward_headers and _response_headers to filter against each respective constant.
Tests for encoding header stripping
tests/test_loop_backend_proxy.py
Adds content-encoding: gzip to the upstream mock response and asserts it is absent in the proxied response; introduces test_loop_proxy_does_not_forward_accept_encoding to verify Accept-Encoding is not present in upstream request headers.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐇 Hop-by-hop, I hop along,
Stripping headers all day long!
accept-encoding? Not for you!
content-encoding? Adieu, adieu!
The proxy hops but leaves no gzip trace —
A tidy tunnel, neat and in its place. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(proxy): strip encoded loop headers' clearly and concisely summarizes the main change—removing encoding headers from loop backend proxy requests and responses.
Description check ✅ Passed The description is directly related to the changeset, explaining the context, implementation details (dropping Accept-Encoding and Content-Encoding headers), and verification approach.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/loop-proxy-header-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jon-devlapaz jon-devlapaz merged commit bb90b05 into main Jun 16, 2026
5 checks passed
@jon-devlapaz jon-devlapaz deleted the feat/loop-proxy-header-fix branch June 16, 2026 22:51

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4fc6c86d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread loop_backend_proxy.py
)

_REQUEST_HEADER_DENYLIST = _HOP_BY_HOP | {"accept-encoding"}
_RESPONSE_HEADER_DENYLIST = _HOP_BY_HOP | {"content-encoding"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve unsupported response encodings

Because this drops Content-Encoding for every upstream response, responses whose bytes were not decoded by urllib3 become corrupt. That happens for encodings urllib3 does not support in this runtime, for example br because the repo does not install brotli/brotlicffi, or for any backend that sends encoded bytes despite the identity request; upstream.read() returns the encoded payload, but the browser no longer sees the header needed to decode it. Please either disable urllib3 decoding and preserve the header, or strip it only when the payload was actually decoded.

Useful? React with 👍 / 👎.

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.

1 participant