fix(cli): keep TUS upload failure detail instead of "unknown error"
Merged
PO
3mo ago+18+18+01234567890123456789-3-3-0123456789
Summary
- A failed
capgo bundle uploadwith an empty response body reached the user as the literal stringunknown 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
uploadTUSonErrorhandler ranJSON.parseoutside any try/catch and rejected a bare string, so an empty body collapsed tounknown errorand a non-JSON proxy page (HTML 502/504) threw aSyntaxErrorinside 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 realError.
| 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
Errorcarrying the status, URL, and body instead ofunknown 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.tsbut fixes the neighbouring$exception_fingerprintproblem infindSavedKey; it leaves theuploadTUShandler alone, so the two do not conflict.
Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.