fix: decode zstd-compressed Codex request bodies - #30
Open
Anionex wants to merge 7 commits into
Open
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #29.
Codex Desktop compresses larger request bodies with
Content-Encoding: zstd. The proxy previously passed those bytes directly tojson.loads, so image requests raisedUnicodeDecodeErrorand surfaced as a misleading 502.This change:
zstd,gzip/x-gzip, anddeflate);libzstd, with an already-installedzstandardbinding as a final compatibility fallback;Content-Encodingbefore forwarding the decoded body upstream;UnicodeDecodeErrorto escape;function_call_output.outputimage input, including image rewrite and upstream header assertions;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.pypython3 tests/test_image_rewrite_shapes.pypython3 tests/test_focus_hint.pypython3 tests/test_anthropic_rewrite.pypython3 tests/test_request_content_encoding.pypython3 tests/smoke_test_proxy.pypython3 tests/smoke_test_egress_failover.pypython3 tests/test_vision_client.pypython3 tests/test_html_shot.pypython3 tests/test_restore_ui_playbook.pypython3 tests/test_trace.pypython3.11 tests/test_request_content_encoding.pypython3.14 tests/test_request_content_encoding.pypython3.14 tests/smoke_test_proxy.pygit diff --checkThe 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_imageResponses payload. The proxy returned 200, rewrote theinput_image, forwarded decoded JSON, and removedContent-Encoding. Invalid zstd returned 400 and unsupportedbrreturned 415.