Fix: normalize packageManager "unknown" to "npm" before it hits PackageManagerEnum - #419
Open
giomartinsdev wants to merge 1 commit into
Open
Fix: normalize packageManager "unknown" to "npm" before it hits PackageManagerEnum#419giomartinsdev wants to merge 1 commit into
giomartinsdev wants to merge 1 commit into
Conversation
…to the client
detectPackageManager() legitimately returns "unknown" when no manifest is
found anywhere in the scanned root (e.g. a docker-compose-only subfolder
in a monorepo, no package.json/go.mod/requirements.txt/etc). That's a
valid internal sentinel — applyWorkspaceContext already special-cases it
— but it isn't a real package manager, and PackageManagerEnum
(project.schema.ts, derived from the STACKS registry) never included it
as a literal.
Two builders echoed the raw value straight into API responses the
dashboard persists verbatim into subsequent project-creation requests:
ProjectInfo (prepare.service.ts, the single-root/declared-compose path)
and MonorepoApp (project-root-detector.ts, the monorepo sub-app path).
Either one 400s with "Expected union value" the moment a user deploys a
compose stack that lives in a subfolder with no manifest of its own —
which is the common case for a pure-infra monorepo (a repo of several
infra/<service>/docker-compose.yml folders, one Openship project per
folder).
Fixes both leak points by normalizing "unknown" to "npm" right where the
value is produced — the same default the dashboard's own `|| "npm"`
fallbacks already assume, now applied where it's actually needed instead
of scattered across every read site.
Added a regression test in prepare.service.test.ts reproducing the exact
shape that broke: a docker-compose.yml in a subfolder with zero manifest
files, scanned via a declared composePath. Confirmed it fails without the
fix ('unknown' !== 'npm') and passes with it.
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.
Closes #418
Summary
detectPackageManager()returns the internal sentinel"unknown"when no manifest is found anywhere in the scanned root — legitimate (applyWorkspaceContextalready special-cases it), but not a real package manager, andPackageManagerEnum(derived from theSTACKSregistry) never accepted it as a literal.Two builders echoed the raw value straight into API responses the dashboard persists verbatim into the next project-creation request, which validates against that strict enum and 400s with "Expected union value":
resolveProjectInfoinapps/api/src/modules/deployments/prepare.service.ts(single-root / declared-compose-path case)toMonorepoAppinapps/api/src/lib/project-root-detector.ts(monorepo sub-app case)Fixed both at the point the value is produced —
"unknown"→"npm"— rather than patching every read site (the dashboard has a dozen-plusresponse.packageManager || "npm"fallbacks that all silently miss this because"unknown"is truthy).Test plan
prepare.service.test.ts) reproducing the exact repro: adocker-compose.ymlin a subfolder with zero manifest files, scanned via a declaredcomposePath. Verified it fails without the fix (expected 'unknown' to be 'npm') and passes with it.bunx vitest runacross the wholeapps/apipackage — 171 test files, 1859 tests passing (15 pre-existing skips, unrelated), no regressions.bunx tsc --noEmitinapps/api— clean.