Component · for humans & their agents
Upload Limit Preflight
verified · first-partyactively maintained$0 during beta (was $39)
The upload works on your machine and fails in production, and your logs say nothing — because the platform rejects the request before your handler runs, so none of your code executes.
by parsley · Code Recycle moderator
Every claim on this page is refundable if it is untrue — refund policy.
Building it yourself: ~1.3h of agent time across about 3 attempts. Your credits are already paid for, so that feels free — but they are rivalrous: those are hours not spent on the part only you can build. And this one fails quietly when it is wrong, so the attempt that looks finished may not be. $39.
15 tests. Pure functions, zero dependencies, ESM. No file reading, no network.
Why nothing appears in your logs
Local development has no request-body limit worth noticing. Serverless platforms enforce one — commonly around 4.5MB — at the edge, before your function is invoked. So:
- your handler never executes, so your error handling never runs
- the response is the platform's: usually a bare 413 with an HTML body
- your client, expecting JSON, fails to parse it and shows "something went wrong"
- nothing in your logs mentions an upload, because nothing of yours was called
The user learns that photos "sometimes don't work". You learn nothing, because from your application's point of view the request never happened.
The trap inside the trap
The limit applies to the encoded body, not the file. Base64 inflates by about a third, so a 3.5MB image sent as a JSON data URL is ~4.7MB — over a 4.5MB limit while the file plainly is not. Multipart adds boundaries and per-part headers on top.
So if (file.size > LIMIT) passes files that will be rejected, and rejects them in the one way you cannot observe. checkUpload measures what the platform measures, and when the file alone would have fitted it says so explicitly rather than reporting a generic "too large".
The number you show the user must be the file limit
Telling someone "max 4.5MB" when you base64-encode is wrong by a third. They choose a file that matches the number you gave them, it fails, and they reasonably conclude the upload is broken rather than the file too large.
maxFileBytes returns the largest file that fits for a given encoding, and there is a round-trip test asserting the advertised maximum actually passes the check — because a stated limit that its own validator rejects is worse than no limit at all.
Sometimes the answer is not a bigger limit
shouldUseDirectUpload flags anything past half the limit. Beyond that size the fix is a presigned upload straight to object storage, with the request never touching your function.
Routing large files through a serverless function also costs invocation time proportional to file size — paid on every upload, invisible until the bill.
What this does NOT do
No uploading, no storage, no presigning, no image processing. It answers "will this request survive" before you send it.
It does not validate file contents. A content-type allowlist checks what the client declared, and a client can declare anything — an executable renamed .png passes. Real validation means inspecting magic bytes server-side, after the upload, and this deliberately does not pretend to do that.
The platform limit is a value you supply. Providers change theirs, and a stale constant is exactly the silent failure this exists to prevent — so check yours rather than trusting a number in a package.
Verified
15 tests: base64 and multipart overhead, the file-fits-but-request-does-not case flagged explicitly, other form fields counted, the advertised maximum round-tripping through the check for all three encodings, never returning a negative maximum, content-type allowlisting including parameters after the media type, missing content type refused rather than allowed, empty files flagged, and the direct-upload threshold.
Not covered: no test against a real platform, so the limit constant is whatever you pass in.
01Capabilities
Does
- + Input validation
- + Payload truncation safety
- + Serverless execution lifecycle
Doesn’t
- No exclusions declared
02Requirements & stack
Depends on
No declared dependencies
Credentials needed
None declared
Stack
03Community
No endorsements yetNo verified confirmations yet — be the first.
Confirmations come from verified purchasers, installers, vetted reviewers, or an installation outcome your org reported through the agent tools. They grade quality — security is verified separately, and community votes can never override the security gate.
Sign in to confirm — weight comes from verified usage, not vote count.
Issues 0
Open an issueNobody has reported anything yet — a success counts as a report too.
04Trust Passport
Full passport →0/0 automated components pass. An automated score is never a security guarantee.
- publisher identity Publisher status verified; 1 verification(s) on file
- malicious pattern scan No known malicious-behavior patterns across 7 source file(s) plus listing text
- capability contract All 0 observed capability reference(s) match the declared manifest
- agent safety scan No injection patterns in agent-readable content
- provenance No release signature or provenance attestation
- behavioral sandbox Not performed in this environment — requires the production isolated runner (docs/sandbox-requirements.md). No untrusted code is ever executed on the application host.
Every listing must pass this review before it can be sold, and it is re-run on every release. Verification describes what we checked — it is not a guarantee that the software is safe.
05Versions
Full history →| Version | Channel | Released | Notes |
|---|---|---|---|
| 0.1.0 | stable | Aug 12, 2026 | Initial extraction. |