fix(cli): recover bundle zip setup failures before aborting
Merged
PO
2mo ago+260+260+012345678901234567890123456789-12-12-01234567890123456789
Summary
- Who is hurt: genuine CLI crashes get buried.
bundle zip's five expected user-configuration aborts still open error tracking$exceptionissues, sharded across many fingerprints, which keep resurfacing as brand-new issues. - Root cause:
cli/src/bundle/zip.tsthrew bareErrorin five places, soshouldCapturePosthogExceptionnever skipped them — unlikebundle upload, which routes every abort throughuploadFailand throwsCliUserError. - Fix: swap the five bare
throw new Error(...)calls forCliUserError(fromcli/src/shared/cli-user-error.ts).shouldCapturePosthogExceptionalready skips that type.
The user experience was already correct — each site prints a clear message and a machine-readable emitJsonError code before it throws. Only the telemetry was wrong.
Site (zip.ts) | Message | JSON code |
|---|---|---|
| Semver check | Invalid bundle version format | invalid_semver |
| Missing argument | Missing appId/bundle/path | missing_argument |
| notifyAppReady | notifyAppReady() is missing in build folder | notifyAppReady_not_in_source_code |
| index.html | index.html is missing in root folder | index_html_not_found |
| updater plugin | Cannot find @capgo/capacitor-updater in node_modules | (warn) |
Notes:
- No
zipFailhelper was added. Each site already gates its logging inline onsilent/json, so a helper would not co-locate log + throw the wayuploadFaildoes — it would only add indirection. - The catch block (
error instanceof Error ? error : new Error(String(error))) passesCliUserErrorstraight through, since it extendsError. Exit codes and analytics events are unchanged; only the$exceptioncapture goes away.
Test plan
bundle zipon a build folder missingnotifyAppReady()still prints the same error and exits non-zero, but no error tracking$exceptionissue is opened.- Verify each of the five aborts (bad semver, missing argument, missing
notifyAppReady, missingindex.html, missing updater plugin) behaves as before, in both default and--jsonoutput.
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
Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by CodeRabbit
-
New Features
- Added interactive recovery for invalid or missing bundle versions.
- Added prompts to locate missing web directories.
- Added automatic installation or restoration of missing updater components.
- Added local fallback version handling when bundle metadata is unavailable.
- Added retries for updater discovery after recovery actions.
-
Bug Fixes
- Improved bundle creation reliability when app-readiness notifications fail.
- Added clearer error reporting and input validation during recovery.
- Improved installation checks to confirm updater recovery succeeded.