Skip to content

fix(artifacts): record why a bundle download falls back to the inline endpoint - #324

Merged
riglar merged 1 commit into
devfrom
fix/log-bundle-fallback-reason
Nov 16, 2026
Merged

riglar merged 1 commit into
devfrom
fix/log-bundle-fallback-reason

Conversation

@riglar

@riglar riglar commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Why

Artifact and HTML-report downloads try bundle delivery first: a signed manifest from the API, then a ZIP streamed from the delivery service. If anything about that goes wrong, the CLI silently falls back to the inline download endpoint. The user still gets their file, which is the point. But tryBundleDownload returned a bare false from seven different places. So the fallback left no record of why: a deployment without bundle delivery, a non-OK response, a dropped connection, or a stream that broke partway all looked the same.

What changed

  • tryBundleDownload now calls a new attemptBundleDownload, which returns true or a reason:
    • manifest_request_failed, manifest_unavailable (501), manifest_http_error, manifest_invalid_json, manifest_incomplete
    • bundle_request_failed, bundle_http_error, bundle_stream_failed
  • On a fallback, tryBundleDownload sends a bundle download fell back telemetry event (context cli.download) through the existing telemetry service. It carries:
    • reason, route (e.g. artifacts-bundle), upload_id and duration_ms;
    • status for HTTP errors;
    • error_name, error_message and error_code (the low-level cause, e.g. UND_ERR_SOCKET) for thrown errors;
    • bytes_received for a stream that broke partway. This is counted as bytes arrive, because the partial file on disk understates it: the write stream is torn down with buffered bytes still unflushed.
  • A 501 is logged at info, since it's the expected answer from a deployment without bundle delivery. Everything else is logged at warn.
  • Nothing is printed. The MCP server uses the same gateway, and its stdout is the JSON-RPC channel. Behaviour is unchanged: the same fallback still happens in the same cases.
  • DCD_TELEMETRY_DISABLED=1 turns the event off, like all CLI telemetry.

Testing

  • New unit tests in report-download.service.test.ts:
    • nothing is recorded on success;
    • a 501, with route and upload id;
    • an incomplete manifest;
    • a non-OK bundle response;
    • a stream that sends some bytes and then breaks, checking the error code and bytes received, and that the inline download still replaces the partial file.
  • pnpm typecheck, pnpm lint (no new warnings), pnpm test:unit (576 passing), pnpm build.

🤖 Generated with Claude Code

… endpoint

tryBundleDownload returned false at seven different points, and the
fallback is silent: the inline download still delivers the file. So
there was no way to tell a deployment without bundle delivery from a
dropped connection or a stream that broke partway.

Each point now returns a reason, and tryBundleDownload sends it as a
"bundle download fell back" telemetry event (context cli.download) with
the route, upload id, duration, HTTP status or error name/message/code,
and the bytes received before a stream broke. A 501 (no bundle delivery
on this deployment) is logged at info; everything else at warn.

Nothing is printed: the MCP server uses the same gateway, and its
stdout is the JSON-RPC channel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@riglar
riglar merged commit e539bd7 into dev Nov 16, 2026
9 checks passed
@riglar
riglar deleted the fix/log-bundle-fallback-reason branch November 16, 2026 21:18
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