Skip to content

fix(workspace-source): read apply and plan bodies past 10 MiB, refuse oversized ones locally - #10541

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/wac-qa-b4-workspace-body-ceiling
Dec 1, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/wac-qa-b4-workspace-body-ceiling

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A workspace source apply or status over 10 MiB got a bare 413. POST /api/v2/workspaces/{id}/source and /source/plan declared a 58 MB body cap (WORKSPACE_SOURCE_REQUEST_MAX_BYTES), but apps/sim/proxy.ts matched them. Next therefore buffered the body at its 10 MiB proxy limit, and the route clamped its cap to match. A rows file of a few thousand rows (well under maxRowsBytes, 16 MB) is resent on every apply. So after one large table, every later apply, including one that only edits a workflow, answered "Request body is too large".

  • Both routes are now left out of the proxy matcher, as the desktop upload and document-persist routes already are. They declare bypassesProxy, so their own 58 MB cap is the one in force. The blob staging routes stay proxied, by design. The proxy only sets CORS headers on /api, so the two routes lose nothing for their callers: the CLI and same-origin requests.
  • The CLI measures the JSON body before sending an apply, a --to promotion or a status. Over the cap, it refuses with SOURCE_TOO_LARGE (exit 7) and names the bytes each folder carries and the --only split to use. Status now also counts the whole body when it decides whether it can send every workflow folder whole. It falls back to sending unchanged folders by their base, as it already does past the workflow budget.
  • The exit-7 help and the self-hosting request-size docs say the same.

workspaces source check skipped a table whose declaration does not read. The table codec's own findings were dropped (if (!decl) continue), so an option listed twice or an unsupported currency code passed check clean, and that table's rows file went unchecked. Check now reports each declaration finding at its file and line.

declaredKeys was implemented twice (sim-cli and @sim/workspace-code/promote). It now lives once in @sim/workspace-code/kinds/registry. It takes an optional paths argument, so promotion still counts the blob paths.

Not changed

  • Leaving unchanged rows and declaration files out of the body: the server reads a managed table without its rows file as zero rows, and a table with no files as undeclared. Doing this would need a new protocol marker. With the cap fixed, it is a bandwidth saving, not a correctness fix.
  • The one-ttl-column limit is still reported by the dry run, not by offline check: the column-type catalog that holds it lives only on the server.

Tests

Each of these failed on the pre-fix code, with that guard reverted, and passes now:

  • proxy.test.ts: Next's own matcher leaves /source and /source/plan unbuffered and still runs for /source/blobs*.
  • Source and plan route tests: a body of about 15 MB reaches the use case whole.
  • CLI apply (--dry and --yes): a body over the cap exits 7 before any request or blob staging, naming bytes by folder and the --only split.
  • Plan route: once the plans in flight hold as many bodies as their slots, a further body is refused with 429 unread, and every answered request, a 400 included, frees its room.
  • CLI status: a directory over the cap as a whole sends its unchanged workflow folder by its base.
  • CLI check: a table declaration with a duplicate option and a bad currency code fails at lines 7 and 8.
  • The get-test table fixtures were declarations the server refuses (no import, no columns). They are now valid.

Risks

  • The two routes now read up to 58 MB per request instead of 10 MiB. A body's room (its declared length, or the cap when it declares none) is reserved in its lane, plan or apply, before the body is read: a lane holds at most as many bodies at the cap as it has slots, and a body past that room answers 429 without being read. defineV2JsonRoute gains reserveBody, a hold that is released however the request ends.
  • Self-hosted reverse proxies must allow 58 MB on these two paths. This is documented in the self-hosting networking page.
  • Offline check now fails on table declarations the server would refuse. Agents that relied on check passing them will see the error one round earlier.

Type of Change

  • Bug fix

Testing

  • Targeted: proxy.test.ts, source and plan route tests, sim-cli suite (1335), workspace-code suite (164), test:scripts
  • Each new test was shown red with its guard reverted, then green
  • bun run lint, bun run type-check (apps/sim, sim-cli, workspace-code), bun run check:audits (only a local knip miss on the gitignored, unbuilt apps/docs/.content), bun run generate (no drift)

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Dec 1, 2026 6:10am UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 21 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no new actionable issues were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Workspace source apply and plan requests now bypass the 10 MiB proxy buffer and use their 58 MB body cap.

  • Workspace source apply and plan routes read bodies up to 58 MB.
  • The CLI checks source request sizes before sending them.
  • Offline source checks report errors in unreadable table declarations.
  • The CLI and promotion code use one shared helper to find declared keys.

Both earlier, unnumbered findings are addressed: large bodies are bounded before parsing, and oversized --yes applies are checked before staging.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Apply or plan request] --> B[Authenticate and rate limit]
  B --> C{Room for body?}
  C -->|No| D[429 without reading body]
  C -->|Yes| E[Read and check body]
  E --> F[Run in source slot]
  F --> G[Build response]
  E --> H[Release body reservation]
  G --> H
Loading

Reviews (2) · Last reviewed commit: "fix(workspace-source): reserve body room..." · Reviewed by Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 24 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 60b5181 into staging Dec 1, 2026
88 of 89 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/wac-qa-b4-workspace-body-ceiling branch December 1, 2026 07:03

This branch was previously deployed

1 inactive deployment
Preview — a471ce31 Deployed Dec 1, 2026 by vercel[bot]
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.

1 participant