Skip to content

Forward TypeSafe image opt-in and multipart uploads for Jev - #161

Open
skyfallwastaken wants to merge 2 commits into
neofrom
jev-forward-danger-zone-headers
Open

skyfallwastaken wants to merge 2 commits into
neofrom
jev-forward-danger-zone-headers

Conversation

@skyfallwastaken

Copy link
Copy Markdown
Member

Jev image requests failed for two reasons.

  • Opt-in header dropped: the route builds its own upstream headers (content-type and the gateway key), so a client's TypeSafe-Danger-Zone-Images: true never reached TypeSafe, which rejects image requests without it. The route now forwards every TypeSafe-Danger-Zone-* header on /systemone and /models. Other client headers are still dropped.
  • Multipart uploads rejected: TypeSafe's recommended way to send images is multipart/form-data, with the JSON body in a request part and each image as a file part. The route only read JSON, so these returned 400. It now abuse-screens the request part, validates and defaults the model the same as for JSON, and forwards the form with its file parts unchanged. Analytics store only the JSON part.
Request Before After
JSON + data_base64 image + opt-in header TypeSafe 400 (header missing) Forwarded with header
Multipart upload + opt-in header Gateway 400 "must be valid JSON" Forwarded as multipart
Plain JSON, no images Works Unchanged

Verified with two regression tests that fail without the change, the full gateway suite (135 pass), typecheck, svelte-check, and a scratch end-to-end curl -F run through a real HTTP gateway against a fake TypeSafe server. Image bytes arrived unchanged, and bad models and missing keys were still rejected. Not exercised against the live TypeSafe API.

Not covered: the TypeSafe JS SDK zstd-compresses request bodies of 1 KiB or more by default on Node 22.15+, and the gateway answers those with 400. SDK users need compression: false until request bodies are decompressed.

ampagent and others added 2 commits October 26, 2026 21:36
The Jev route built its upstream headers from scratch, so a client's
TypeSafe-Danger-Zone-Images: true never reached TypeSafe and image
requests were rejected.

Amp-Thread-ID: https://ampcode.com/threads/T-01a17a1f-c07b-7201-a05b-7e5423f4420a
Co-authored-by: Mahad Kalam <[email protected]>
TypeSafe takes images as file parts of a multipart/form-data request
whose request part holds the JSON body. The route only read JSON, so
those uploads failed with a 400. It now validates and defaults the
model in the request part and forwards the form with its file parts.

Amp-Thread-ID: https://ampcode.com/threads/T-01a17a1f-c07b-7201-a05b-7e5423f4420a
Co-authored-by: Mahad Kalam <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 26, 2026 21:49

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

This branch has not been deployed

No deployments
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.

3 participants