fix(cli): don't crash on empty bundle list or hoisted monorepo deps - #2884
Draft
posthog-eu[bot] wants to merge 1 commit into
Draft
fix(cli): don't crash on empty bundle list or hoisted monorepo deps#2884posthog-eu[bot] wants to merge 1 commit into
posthog-eu[bot] wants to merge 1 commit into
Conversation
- displayBundles now renders an empty state and returns instead of throwing "No bundle found", so `bundle list` on an app with zero bundles exits 0. - getLocalDependencies validates dependencies by walking up parent node_modules directories (matching getAllPackagesDependencies), so deps hoisted to a workspace/monorepo root are no longer reported as missing. - Drop the `.catch(() => [])` that swallowed genuine read errors into an empty array. - Exclude the CLI version from the exception fingerprint so the same bug stays one error-tracking issue across releases. Generated-By: PostHog Code Task-Id: 53a6eb16-3315-4a2b-bfcf-c0d3c122346b
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Two normal situations make the CLI exit non-zero instead of behaving sensibly. This fixes both, plus a fingerprint quirk that hides their true reach.
bundle liston an app with zero bundles printedActive versions in Capgo: 0and then threwNo bundle foundon that same empty array — skippingoutro('Done ✅')and exiting 1. Nastiest in CI, where exit 1 fails the job.displayBundlesnow renders an empty state and returns;bundle cleanup(same call site) is fixed for free.getAllPackagesDependencies) walks up parent directories for hoistednode_modules, but the validation ingetLocalDependenciesonly checked a flat[cwd()/node_modules]. Anything hoisted to a workspace root therefore failed withMissing dependencies or invalid dependencies, blockingbundle upload/doctor. Validation now uses the same parent-directory walk, so enumeration and validation agree.cli:${version}, so the identical bug became a brand-new "1 user" issue on each release. The CLI version is now excluded from the fingerprint (still sent asdistinct_id/cli_version).Also drops a
.catch(() => [])ingetLocalDependenciesthat swallowed genuinenode_modulesread errors into an empty array.Test plan
bun test/test-posthog-exception.mjs— asserts the fingerprint no longer contains the CLI version.bun test/test-native-dependencies.mjs— adds a monorepo-hoisting scenario (dep at the workspace-rootnode_modules, resolved from the app dir with no--node-modules).bun run typecheckandbun run lintpass.Screenshots
N/A — CLI exit-code / error-handling change.
Checklist
bun run lint:backend && bun run lint.Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.