Skip to content

[Request]: support multipart/binary file uploads to functions #132

Closed

Description

@jimhoyd

Problem or use case

docs/HTTP.md already names this as out of scope today: "Schema validation, multipart/file uploads, streaming, content negotiation... [are] out of scope." Function requests are decoded as UTF-8 text/JSON only (docs/SPECIFICATION.md: "Requests decode body bytes as UTF-8. Binary/streaming bodies... out of scope").

Concrete use case surfaced while scoping a port of place-page (a curated-place/trip-planning app) onto URLCode: its "Import" feature accepts pasted text, a URL, a PDF, or a screenshot and parses it into structured places via an LLM call (backend/app/services/ai_extract.py, pdf_extract.py). The text/URL cases fit URLCode's existing JSON function contract fine. The PDF/screenshot cases need a binary file to reach a function at all, which the sandbox currently has no path for.

Proposed behavior and alternatives

Accept multipart/form-data (and/or raw binary bodies) into a function within the existing response/body byte ceilings — no new execution capability, no filesystem, no streaming: just widening what shape of input a function can receive, decoded as a bounded byte buffer (or a small number of named parts) rather than forced through UTF-8 text/JSON decoding.

Alternatives considered: keep this entirely out of scope and require the operator to proxy such uploads to an external service directly (bypassing the sandbox) — reasonable as a permanent answer if multipart support turns out to conflict with the sandbox's isolation/size guarantees, but worth evaluating explicitly rather than leaving as an unstated gap, since more than one candidate project (this port, and general "accept an uploaded document" use cases) hits it. Portability/security note: should stay within the same per-request byte ceilings already enforced (maxBytes), just changing what content-types are accepted rather than raising any limit.

Activity

  1. added
    enhancement
    on Sep 19, 2026
  2. jimhoyd commented on Sep 19, 2026

    @jimhoyd
    CollaboratorAuthor

    Revisiting this after main landed trusted-by-default function/middleware execution (#127, docs/SPIKE-DEFAULT-TRUST-MODEL.md) — this looks resolved for the default (non-sandboxed) path, not something that still needs building:

    • src/trusted-functions.ts constructs a real Node Request from the raw, undecoded request body bytes (body: request.body as Uint8Array), not the sandbox's restricted text/JSON-only guest API. A trusted handler can call req.formData() / req.arrayBuffer() directly.
    • checkRequest in src/http-policy.ts only enforces UTF-8/JSON decoding when a route opts into request.body.format/contentTypes — with no such policy declared, raw bytes (including multipart) pass through untouched to the handler.

    So a trusted route today can already accept multipart/form-data or arbitrary binary bodies, within the existing maxBytes cap — no schema or execution change needed. This was correctly out of scope for the sandboxed guest API (still true for any route that opts into sandbox: true, e.g. genuinely untrusted third-party input), but that's a narrower case than this issue originally described.

    Docs worth a pass for accuracy here: docs/HTTP.md's capability matrix still lists multipart as unconditionally out of scope, which is now only true for the sandboxed path.

    Closing as resolved by the trust-model change rather than tracking further work; reopen if end-to-end testing turns up a gap I missed in the trusted path.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions