Resolve the composer section's configPath against the file that declared it - #262
Conversation
…red it prisma.config.ts is now a chain rather than a single file: the engine discovers every file from the command's cwd up to the repo root and merges their sections per key. A `composer` section written once at the repo root therefore reaches commands run in any subdirectory — and resolving its `configPath` against the process cwd names a different file in every one of them, which is almost never the file the author meant. The section validator now resolves `configPath` itself, through the engine's `resolveSectionPath`, against the file whose section declared that key; an absolute path passes through unchanged. Everything downstream — the pipeline and the config loader — receives an absolute path and no longer resolves anything against cwd. This needs @prisma/cli-engine 0.3.0, whose `ConfigSection.validate` takes the resolved section's provenance as a second argument and whose `LoadedConfig` is the chain rather than one file. Every engine declaration moves to 0.3.0 together, as check-cli-engine-pin requires. 0.3.0 is not published yet (it comes from prisma/prisma-cli#233), so `pnpm install` cannot resolve it and pnpm-lock.yaml cannot be regenerated here. CI stays red until the engine publishes; the lockfile update belongs to the commit that follows the publish. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: Comment |
Engine 0.5.0 carries the config chain and the validator provenance API this branch consumes. Main's pins are taken wholesale (composer 0.21.0 workspace versions, the removed pn-widgets example stays removed). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
|
✅ Gizmo reviewed fb670a5 — posted 0 inline comment(s) this pass. Open findings: none Change walkthroughChange walkthroughThis PR makes the Section validator — section.ts:53 takes the section's provenance as a second argument and runs Load path — the delta since the last reviewed commit adds the receiving end of that contract. load-config.ts:308 replaces the silent Engine pin — all engine declarations move together from Tests — the regression test in engine-cli.test.ts builds the actual two-file chain (root declares, cwd two directories down) where both wrong answers are distinguishable; section.test.ts covers the validator's resolution, pass-through, and no-throw contract; host-adapter.test.ts asserts the resolved path end to end through the real Runtime; and load-config.test.ts:181 pins the new absoluteness guard. |
commit: |
There was a problem hiding this comment.
New findings: 🟡 2 minor · trace
Findings outside the diff
- 🟡 Minor · consistency pnpm-lock.yaml — pnpm-lock.yaml still pins @prisma/cli-engine 0.4.0, so the tree does not install until the 0.5.0 publish and its lockfile follow-up
All seven@prisma/cli-enginepins move to 0.5.0 while pnpm-lock.yaml still resolves 0.4.0, sopnpm install(and any--frozen-lockfileCI job) fails until@prisma/cli-engine@0.5.0publishes — the PR description discloses this and defers the lockfile regeneration to the commit following the publish, matching the repo's prior engine-bump flow. Until that follow-up lands, the merged tree is uninstallable from the registry.
Recommended fix: Regeneratepnpm-lock.yamlagainst the published@prisma/cli-engine@0.5.0in the follow-up commit, as the PR description already plans.
The section validator resolves configPath against the declaring file now; this test predates that and still expected the raw relative path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
There was a problem hiding this comment.
New findings: none · trace
Still open from previous reviews: 🟡 1 minor
path.join(path.sep, ...) builds a rootless path that resolve() prefixes with the process drive on Windows; building fixtures and expectations with path.resolve keeps both sides identical on every platform. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
There was a problem hiding this comment.
New findings: 🟠 1 major · trace
Still open from previous reviews: 🟡 1 minor
A relative configPath reaching configSource resolves against the request's cwd rather than the Node process's, and the pass-through test builds its absolute input with path.resolve like its siblings. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
The contract says the section validator already resolved it, so the relative fallback was dead code contradicting the doc one line above. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
There was a problem hiding this comment.
New findings: 🟠 1 major · 🟡 1 minor · trace
Findings outside the diff
- 🟠 Major · correctness packages/0-framework/3-tooling/cli/package.json — PR pins @prisma/cli-engine@0.5.0 but the lockfile cannot be regenerated until that version publishes — CI is red as committed
Every@prisma/cli-enginedeclaration moves from 0.4.0 to 0.5.0 (the CLI runtime dep, composer-cli's peer and dev pins, the target extension, and all four examples — all verified consistent, no 0.4.0 stragglers), but pnpm-lock.yaml is not updated in this PR because the registry does not yet have 0.5.0. As committed,pnpm installfails and every CI job is red. The PR description discloses this and defers the lockfile to a follow-up commit, so it is a known, deliberate state — but reviewers should not merge until the engine publishes and the lockfile lands, and the description's version numbers are stale: it repeatedly cites engine 0.3.0 andcheck:cli-engine-pin"passing at 0.3.0", while the diff pins 0.5.0. Note also the new code depends on 0.5.0 engine API shapes (SectionProvenanceas the validator's second argument,LoadedConfigas afiles[]chain), so this PR is unbuildable against 0.4.0 even if the pin were reverted.
Recommended fix: Merge only after@prisma/cli-engine@0.5.0is published, and include the regeneratedpnpm-lock.yaml(or land it as the immediately-following commit before any merge to the default branch). Update the PR description's version references to 0.5.0.
CONFIG.PATH_NOT_ABSOLUTE names the skipped contract — the section validator resolves against the declaring file — rather than letting fs and c12 quietly resolve against the process cwd. Tested. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
… against its config file composer 0.22.0 resolves the composer section's relative configPath against the prisma.config.ts that declared it, not against the process cwd (prisma/composer#262). The bin test still expected the cwd-based path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
What changed
The
composerconfig section resolves itsconfigPathagainst the prisma.config.ts file that declared it, instead of against the directory the command happens to run in.prisma.config.ts is now a chain rather than a single file: prisma-cli discovers every config file from the command's cwd up to the repo root and merges the sections per key. A
composersection written once at the repo root therefore reaches commands run in any subdirectory — and aconfigPathresolved against the process cwd names a different file in each of them, which is almost never the file the author meant.The fix follows the pattern engine 0.3.0 defines: the section validator resolves the path-valued key and returns an absolute path, so nothing downstream ever resolves against cwd.
packages/0-framework/3-tooling/cli/src/family/section.ts—validatetakes the section's provenance as its second argument and runsconfigPaththrough the engine'sresolveSectionPath. An absolute path passes through unchanged.resolveSectionPaththrows when the key is missing from the provenance, which cannot happen for a key just read out of the section, but a section validator must never throw — so even that case becomes aCONFIG.FIELD_INVALIDdiagnostic rather than an internal error blamed on composer.src/load-config.tsandsrc/pipeline.ts—configPathis documented and treated as absolute; the resolution againstcwdis gone.0.3.0together (the internal CLI, composer-cli's peer and dev pins, the target extension, and the four examples), which is whatcheck-cli-engine-pinrequires.Tests
src/family/__tests__/engine-cli.test.tsgains the real regression test: a two-file chain where the root file is the only one declaringconfigPath, with the run's cwd two directories below it. Both wrong answers are visible — resolving against cwd, or against the nearest file on the chain, would name/repo/apps/shop/prisma-composer.config.tsinstead of/repo/prisma-composer.config.ts.src/family/__tests__/section.test.tscovers the validator directly: relative resolves against the declaring file, absolute passes through, and a provenance missing the key fails with a diagnostic instead of throwing.host-adapter.test.tsasserts the resolved absolute path arrives at the operation, end to end through the real Runtime.path.resolve(configPath)(cwd-based) fails 6 of these tests, including both engine-level ones — the tests fail when the behavior breaks.What is green, and what is not
Verified locally against a packed
@prisma/cli-engine@0.3.0tarball installed into the workspace:tsc --noEmitacross all 78 workspace typecheck tasks — clean.turbo run testacross all 66 test tasks — clean, including the local-dev integration suite.@internal/clion its own: 259 tests pass.biome checkon the touched sources — clean.pnpm check:cli-engine-pin— passes at0.3.0.CI will be red until
@prisma/cli-engine@0.3.0publishes (it comes from prisma/prisma-cli#233).pnpm installcannot resolve0.3.0from the registry, so it fails before any job runs, andpnpm-lock.yamlcannot be regenerated in this PR. The lockfile update belongs to the commit that follows the publish — the same shape as the previous engine bumps.🤖 Generated with Claude Code