Skip to content

fix: decode zstd-compressed Codex request bodies - #30

Open
Anionex wants to merge 7 commits into
mainfrom
fix/issue-29-zstd
Open

fix: decode zstd-compressed Codex request bodies#30
Anionex wants to merge 7 commits into
mainfrom
fix/issue-29-zstd

Conversation

@Anionex

@Anionex Anionex commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #29.

Codex Desktop compresses larger request bodies with Content-Encoding: zstd. The proxy previously passed those bytes directly to json.loads, so image requests raised UnicodeDecodeError and surfaced as a misleading 502.

This change:

  • decodes request bodies before JSON inspection (zstd, gzip / x-gzip, and deflate);
  • uses Python 3.14's standard-library zstd decoder when available, otherwise streams through libzstd, with an already-installed zstandard binding as a final compatibility fallback;
  • strips Content-Encoding before forwarding the decoded body upstream;
  • returns explicit 400 responses for invalid compressed bodies and 415 for unsupported encodings;
  • preserves malformed/non-JSON byte passthrough without allowing UnicodeDecodeError to escape;
  • adds a regression covering zstd-compressed function_call_output.output image input, including image rewrite and upstream header assertions;
  • runs the focused encoding test in Linux and Windows CI jobs.

Verification

Passed locally:

  • python3 -m py_compile vision_proxy.py vision_client.py ground.py detect.py bin/glance bin/trace bin/crop skills/vision-tools/scripts/html_shot.py
  • python3 tests/test_image_rewrite_shapes.py
  • python3 tests/test_focus_hint.py
  • python3 tests/test_anthropic_rewrite.py
  • python3 tests/test_request_content_encoding.py
  • python3 tests/smoke_test_proxy.py
  • python3 tests/smoke_test_egress_failover.py
  • python3 tests/test_vision_client.py
  • python3 tests/test_html_shot.py
  • python3 tests/test_restore_ui_playbook.py
  • python3 tests/test_trace.py
  • python3.11 tests/test_request_content_encoding.py
  • python3.14 tests/test_request_content_encoding.py
  • python3.14 tests/smoke_test_proxy.py
  • git diff --check

The optional vtracer / Pillow CLI execution remained skipped because those optional dependencies are not installed; the trace unit checks passed.

User-path verification

This is a non-UI proxy protocol change. The real affected path was exercised end-to-end with a local HTTP client sending a zstd frame shaped like Codex Desktop's view_image Responses payload. The proxy returned 200, rewrote the input_image, forwarded decoded JSON, and removed Content-Encoding. Invalid zstd returned 400 and unsupported br returned 415.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

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.

Codex 桌面端含图片的请求必现 502:代理未处理 zstd 压缩请求体

1 participant