Repository navigation
Forward TypeSafe image opt-in, multipart and zstd uploads for Jev - #161
Merged
Merged
Conversation
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 <mahadkalam1234@gmail.com>
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 <mahadkalam1234@gmail.com>
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.
Jev image requests failed for three reasons.
TypeSafe-Danger-Zone-Images: truenever reached TypeSafe, which rejects image requests without it. The route now forwards everyTypeSafe-Danger-Zone-*header on/systemoneand/models. Other client headers are still dropped.multipart/form-data, with the JSON body in arequestpart and each image as a file part. The route only read JSON, so these returned 400. It now abuse-screens therequestpart, 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.Content-Encoding: zstdbefore parsing and forwards the decoded body. Decoded output is capped atMAX_REQUEST_BODY_BYTES(413 past it); other encodings get 415.data_base64image + opt-in headerVerified with regression tests that fail without each change, the full suite (357 pass), typecheck and svelte-check. A scratch end-to-end run drove the real
@typesafe-ai/sdk0.7.0 under Node 26 with default compression through the route over HTTP to a fake TypeSafe server. The JSON and multipart requests both arrived decoded and were billed, and the image's SHA-256 matched. Not exercised against the live TypeSafe API.🤖 Generated with Claude Code