fix(control-plane): make max upload size configurable (#2313)#2319
Open
nicoloboschi wants to merge 1 commit into
Open
fix(control-plane): make max upload size configurable (#2313)#2319nicoloboschi wants to merge 1 commit into
nicoloboschi wants to merge 1 commit into
Conversation
The Next.js auth middleware buffers proxied request bodies and truncates anything over its default 10MB limit before /api/files/retain can parse the multipart form, so single uploads >10MB silently fail with "Failed to parse body as FormData". Set experimental.proxyClientMaxBodySize, defaulting to 100MB to match the dataplane's HINDSIGHT_API_FILE_CONVERSION_MAX_BATCH_SIZE_MB default and overridable via the new HINDSIGHT_CP_MAX_UPLOAD_SIZE env var (size string or byte count).
|
You beat me to submitting a PR. Thank you! :) Can confirm this patch fixes the issue (tested locally). |
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.
Problem
Fixes #2313. Uploading a single file larger than 10MB via the Control Plane silently fails — the dialog never closes and the logs show:
Root cause
This is the Control Plane (Next.js), not the dataplane. The auth middleware sits in front of
/api/files/retain, so Next.js buffers the proxied request body and truncates anything over its default 10MB limit (DEFAULT_BODY_CLONE_SIZE_LIMIT, configured viaproxyClientMaxBodySize). The route then tries to parse a truncated multipart body and throwsFailed to parse body as FormData, so the request never reaches the dataplane.The dataplane already allows 100MB and is already configurable (
HINDSIGHT_API_FILE_CONVERSION_MAX_BATCH_SIZE_MB), so the Control Plane was the lone bottleneck.Fix
Set Next's
experimental.proxyClientMaxBodySizeinnext.config.ts:100mb, matching the dataplane'sHINDSIGHT_API_FILE_CONVERSION_MAX_BATCH_SIZE_MBdefault.HINDSIGHT_CP_MAX_UPLOAD_SIZEenv var — accepts a size string (100mb,1gb) or a raw byte count.Note: installed Next is 16.2.9, where the canonical key is
proxyClientMaxBodySize(the oldermiddlewareClientMaxBodySizealias is still in the schema but is no longer read).Verification
loadConfig+ zod validation: default100mb→104857600bytes, override250mb→262144000, raw byte counts pass through. No validation errors or unknown-key warnings.tsc --noEmitand./scripts/hooks/lint.shpass.Docs
Added
HINDSIGHT_CP_MAX_UPLOAD_SIZEto the Control Plane table indeveloper/configuration.md.