feat: submit flow tests via client-direct upload#26
Merged
Conversation
The API used to accept the flow zip as a multipart POST /uploads/flow, buffering the whole zip in API server memory (Multer memoryStorage) — a memory-pressure / OOM source in prod. Switch the CLI to upload the flow zip directly to storage (exactly like app binaries already do), then submit the test via a JSON endpoint that references the stored file. - api-gateway: add getFlowUploadUrl + submitFlowTest alongside the binary equivalents. submitFlowTest's response is identical to /uploads/flow. - methods: add uploadFlowZip, mirroring performUpload — write the zip to a temp file and reuse the existing binary uploaders (TUS to Supabase + optional Backblaze), reporting supabaseSuccess/backblazeSuccess honestly. - test-submission: split buildTestFormData into buildTestPayload (zip + every non-file field, encoded exactly as today) and buildFormData (the multipart wrapper for the fallback), so both paths share byte-identical field encoding. - cloud: upload the zip, then submitFlowTest referencing it. On 404/405 (older API deployment) fall back to the legacy multipart /uploads/flow. Response handling and status polling are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
The MCP tool dcd_run_cloud_test (added on dev) called the old TestSubmissionService.buildTestFormData, which this branch split into buildTestPayload + buildFormData. The mismatch only surfaced in the PR merge build. Update the tool to the new client-direct submit path (uploadFlowZip + submitFlowTest) with the legacy multipart fallback, mirroring dcd cloud. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Awaiting dependent API release. |
…t-upload # Conflicts: # src/commands/cloud.ts # src/gateways/api-gateway.ts # src/mcp/tools/run-cloud-test.ts
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.
Why
The API used to accept the flow zip as a multipart
POST /uploads/flow, buffering the entire zip in API server memory (MultermemoryStorage) — a memory-pressure / OOM source in prod. The API now supports uploading the flow zip directly to storage (exactly like app binaries already do), then submitting the test via a JSON endpoint that references the stored file. This PR switches the CLI to that path by default. The old multipart endpoint still exists server-side, so this CLI falls back to it against older API deployments.What changed
api-gateway.ts— new JSON methodsgetFlowUploadUrl(fileSize)(POST /uploads/getFlowUploadUrl,{ fileSize, useTus: true }, same response shape asgetBinaryUploadUrl) andsubmitFlowTest(body)(POST /uploads/submitFlowTest, response identical to legacy/uploads/flow).methods.ts— newuploadFlowZip()mirroringperformUpload: writes the in-memory flow zip to a temp file and reuses the existing binary uploaders (TUS to Supabase bucketorganizations+ optional Backblaze), reportingsupabaseSuccess/backblazeSuccesshonestly. Returns the storage ref forsubmitFlowTest.test-submission.service.ts— splitbuildTestFormDataintobuildTestPayload()(the zip buffer + sha + every non-filefield, encoded exactly as today) andbuildFormData()(the multipart wrapper for the fallback). Both paths share byte-identical field encoding.cloud.ts— upload the zip, thensubmitFlowTestreferencing it. OnApiError404/405 (older API deployment) fall back to the legacy multipart/uploads/flow. Response handling and status polling are unchanged.Backward compatibility
A real older API 404s an undefined route; the Prism mock returns 405 (path matched, method undefined). Either unambiguously means "endpoint unavailable here," so both trigger the multipart fallback. A new API that defines the POST can't return 405, so this can't mask a real failure.
Testing
pnpm typecheck,pnpm lint(0 errors),pnpm build— clean.pnpm test— 128 passing. The mock API has no new endpoints, so the suite exercises the 404/405 fallback end-to-end (submit + poll behave identically to before).Not covered here
The happy-path client-direct upload (zip landing at
<orgId>/tests/<id>.zip, results created) needs a live dev API + credentials and wasn't run in CI. It's type-checked and structurally identical to the proven binary path — worth a manual smoke test against dev before merge.🤖 Generated with Claude Code