fix(cli): throw CliUserError for capacitor config and org lookup
Merged
RI
2mo ago+193+193+012345678901234567890123456789-25-25-01234567890123456789
Summary (AI generated)
getConfigFromthrowsCliUserErrorwith constant messageNo capacitor config file found, run \cap init` first; underlying diagnostics (including TypeScript load failures) go tolog.errorandcontext.cause` instead of the thrown message.resolveCapacitorConfigTargetPaththrowsCliUserErrorwith constant messages for empty / missing / invalid filename / outside-cwd cases; resolved paths live incontext.path.getOrganizationIdthrowsCliUserError('Cannot get organization id for app')with{ appId, cause }in context; enrichedlog.errorunchanged.- Added
test-cli-user-error-config.mjsand updated capacitor-config-target / PostHog exception tests.
Motivation (AI generated)
PostHog project 22029 still groups expected CLI user mistakes as high-volume exceptions because plain Error messages embed dynamic paths, app IDs, and wrapped formatError text — creating unstable fingerprints and noise in error tracking.
Related issues:
- No capacitor config and related “No capacitor config file found, run
cap initfirst …” variants (including TypeScript-missing wrapped messages fromgetConfigFromcatch path). - Capacitor config path user mistakes:
Capacitor config path does not exist: <path>(and empty/invalid/outside-cwd variants) fromresolveCapacitorConfigTargetPath. - Cannot get organization id when app is missing or API key cannot read the app.
Business Impact (AI generated)
Reduces false-positive CLI exception volume in PostHog so engineering can focus on real crashes. Expected user configuration and lookup failures remain visible via trackCommandFailed / failure analytics without opening separate error-tracking issues per path or app ID.
Test Plan (AI generated)
-
bun run build(cli) -
bun run test:cli-user-error-config -
bun run test:posthog-exception -
bun run test:capacitor-config-target -
bun run lint(cli)
Generated with AI


Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by CodeRabbit
-
Bug Fixes
- Improved CLI error messages for invalid, missing, empty, or inaccessible Capacitor configuration files.
- Added clearer path context for unsupported extensions, invalid locations, symlink escapes, and directory targets.
- Improved organization lookup failure reporting with actionable application context.
- Prevented expected user configuration errors from being misclassified as unexpected exceptions.
-
Tests
- Expanded coverage for configuration validation and organization lookup failures.