Skip to content

feat: submit flow tests via client-direct upload#26

Merged
riglar merged 3 commits into
devfrom
feat/flow-client-direct-upload
Jun 23, 2026
Merged

feat: submit flow tests via client-direct upload#26
riglar merged 3 commits into
devfrom
feat/flow-client-direct-upload

Conversation

@riglar

@riglar riglar commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Why

The API used to accept the flow zip as a multipart POST /uploads/flow, buffering the entire zip in API server memory (Multer memoryStorage) — 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 methods getFlowUploadUrl(fileSize) (POST /uploads/getFlowUploadUrl, { fileSize, useTus: true }, same response shape as getBinaryUploadUrl) and submitFlowTest(body) (POST /uploads/submitFlowTest, response identical to legacy /uploads/flow).
  • methods.ts — new uploadFlowZip() mirroring performUpload: writes the in-memory flow zip to a temp file and reuses the existing binary uploaders (TUS to Supabase bucket organizations + optional Backblaze), reporting supabaseSuccess/backblazeSuccess honestly. Returns the storage ref for submitFlowTest.
  • test-submission.service.ts — split buildTestFormData into buildTestPayload() (the zip buffer + sha + every non-file field, encoded exactly as today) and buildFormData() (the multipart wrapper for the fallback). Both paths share byte-identical field encoding.
  • cloud.ts — upload the zip, then submitFlowTest referencing it. On ApiError 404/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 test128 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

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>
@claude

claude Bot commented Jun 22, 2026

Copy link
Copy Markdown

Code review

No 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>
@riglar

riglar commented Jun 22, 2026

Copy link
Copy Markdown
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
@riglar riglar merged commit 2e5445e into dev Jun 23, 2026
6 checks passed
@riglar riglar deleted the feat/flow-client-direct-upload branch June 24, 2026 07:38
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