fix(contract): preserve empty model fields - #30003
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughCanonicalization preserves empty ChangesField-less variant contract handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change preserves required empty model fields in emitted contracts and is covered by targeted tests; no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The canonicalization change preserves fields: {} for field-less variant models. The regression test verifies preservation before and after canonicalization and confirms Mongo schema validation. This satisfies issue
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/2-mongo-family/2-authoring/contract-psl/test/interpreter.polymorphism.test.ts`:
- Line 153: Update both assertions in the polymorphism tests around
modelsOf(ir)['Note'] to verify that fields is exactly an empty object rather
than merely matching an empty subset. Replace each toMatchObject({ fields: {} })
assertion with toHaveProperty('fields', {}) or extract fields and compare it
with toEqual({}).
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: 080c171e-457b-4072-9ade-cf6ee25e7889
📒 Files selected for processing (2)
packages/1-framework/0-foundation/contract/src/canonicalization.tspackages/2-mongo-family/2-authoring/contract-psl/test/interpreter.polymorphism.test.ts
|
@wmadden I noticed you’ve worked on the contract canonicalization path, so you may be a good person to review this. This fixes prisma/prisma-next#1070 by preserving required empty model fields during canonicalization. I’ve also addressed the feedback on the regression assertions, and the targeted tests pass. Thanks! |
3f44102 to
4246b65
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
4246b65 to
209a775
Compare
209a775 to
807a193
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Signed-off-by: Saad Hassan <shgit29@gmail.com>
Signed-off-by: Saad Hassan <shgit29@gmail.com>
807a193 to
64df122
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Linked issue
Fixes #30130
Refs prisma/prisma-next#1070
Summary
Field-less variant models correctly produce
fields: {}during PSL interpretation, but contract canonicalization removed that empty object even thoughfieldsis a required model property.This change preserves empty model
fieldsduring canonicalization so emitted contracts remain structurally valid.Testing performed
pnpm buildpnpm typecheckpnpm lintpnpm test:packages@internal/contracttests@internal/mongo-contract-psltestsgit diff --checkThe full package suite had unrelated transient failures under load; the affected package suites passed when rerun separately.
Skill update
n/a — internal only
Checklist
git commit -s) per the DCO. The DCO status check will block merge if any commit is missing aSigned-off-by:trailer.n/aif the change is doc-only / refactor with no behavioural delta).TML-NNNN: <sentence-case title>form (Linear ticket prefix + concise title naming the concrete deliverable). See.claude/skills/create-pr/SKILL.mdfor the full convention.n/a — internal only).Notes for the reviewer
This issue was originally reported as prisma/prisma-next#1070 and has now been re-filed in the current repository as #30130 after Prisma Next moved to
prisma/prismaas Prisma ORM v8.The fix is applied in generic contract canonicalization rather than the Mongo-specific canonicalization hook because
fieldsis a required model property at the framework contract level.Summary by CodeRabbit
Bug Fixes
Tests
fields: {}before and after canonicalization and pass Mongo schema validation.