Skip to content

fix(cli): keep TUS upload failure detail instead of "unknown error" - #2933

Merged
riderx merged 1 commit into
mainfrom
posthog-self-driving/fixcli-keep-tus-upload-failure-detail-ce6790
Aug 8, 2026
Merged

fix(cli): keep TUS upload failure detail instead of "unknown error"#2933
riderx merged 1 commit into
mainfrom
posthog-self-driving/fixcli-keep-tus-upload-failure-detail-ce6790

Conversation

@posthog-eu

@posthog-eu posthog-eu Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • A failed capgo bundle upload with an empty response body reached the user as the literal string unknown error — the HTTP status, request URL, and raw body were all dropped. This minted a fresh error tracking issue per occurrence and left both the user and the team unable to act.
  • Root cause: the uploadTUS onError handler ran JSON.parse outside any try/catch and rejected a bare string, so an empty body collapsed to unknown error and a non-JSON proxy page (HTML 502/504) threw a SyntaxError inside the tus callback.
  • Fix: port the handler shape that already works in cli/src/build/request.ts — wrap the parse in a try/catch that falls back to the raw body then the tus error message, add the HTTP status and request URL to the message, and reject a real Error.
Case Before After
Empty body unknown error TUS upload failed (status 502, url …): <body or tus message>
Non-JSON body (HTML 502/504) SyntaxError thrown in callback raw body surfaced in a rejected Error
JSON body (invalid_apikey, app_not_found, …) real cause (unchanged) real cause (unchanged)

Test plan

  • No behaviour change for the JSON-body path (invalid_apikey, app_not_found, insufficient_permissions) — those still surface their real cause.
  • Empty-body and non-JSON-body failures now reject a real Error carrying the status, URL, and body instead of unknown error.

Screenshots

Checklist

  • My code follows the code style of this project and passes
    bun run lint:backend && bun run lint.
  • My change requires a change to the documentation.
  • I have updated the documentation
    accordingly.
  • My change has adequate E2E test coverage.
  • I have tested my code manually, and I have provided steps how to reproduce
    my tests

Agent context

  • Complementary to open PR #2932, which also touches cli/src/utils.ts but fixes the neighbouring $exception_fingerprint problem in findSavedKey; it leaves the uploadTUS handler alone, so the two do not conflict.

Created with PostHog Desktop from this inbox report.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

Port the working error handler from build/request.ts into uploadTUS.

The onError handler parsed the response body outside a try/catch and, on an
empty body, collapsed to the literal string "unknown error" while dropping
the HTTP status, request URL, and raw body. A non-JSON proxy page (502/504)
threw a SyntaxError inside the tus callback instead of rejecting cleanly.

Now the parse is wrapped in a try/catch that falls back to the raw body then
the tus error message, the status and URL are included in the message, and a
real Error is rejected instead of a bare string.

Generated-By: PostHog Code
Task-Id: 95f63bcd-1e34-43b5-9bc9-cc0b870250eb
@codspeed-hq

codspeed-hq Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing posthog-self-driving/fixcli-keep-tus-upload-failure-detail-ce6790 (1824b0d) with main (e82dd01)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sonarqubecloud

sonarqubecloud Bot commented Aug 8, 2026

Copy link
Copy Markdown

@riderx
riderx marked this pull request as ready for review August 8, 2026 17:13
@riderx
riderx merged commit 4c75e90 into main Aug 8, 2026
87 of 92 checks passed
@riderx
riderx deleted the posthog-self-driving/fixcli-keep-tus-upload-failure-detail-ce6790 branch August 8, 2026 17:17
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