Repository navigation
Fix nullable Mongo list container validation - #30568
Conversation
…ures Signed-off-by: Steven McClankerton <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (2)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: prisma/orm/.coderabbit.yml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (19)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughNullable many-valued fields now generate schemas that allow the list container to be null, independently of whether list elements may be null. Tests, retail-store contracts and migration snapshots, and upgrade instructions reflect the updated behavior. ChangesNullable list schema generation
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to Nullable Mongo list fields can now hold an explicit null while required lists still reject it, and element rules are unchanged. Existing databases need a new validator migration before they write null lists, as the upgrade instructions describe. No blocking issues were found. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change permits explicit null containers already allowed by nullable-list declarations while preserving required fields and element validation. Existing databases require a migration before using this behavior. No concrete security regression was established, but interrupted upgrades and rollback after null writes are not demonstrated. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 11 files. (8 skipped: 8 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
@prisma/orm-extension-arktype-json
@prisma/orm-extension-middleware-cache
@prisma/orm-extension-paradedb
@prisma/orm-extension-pgvector
@prisma/orm-extension-postgis
@prisma/orm-extension-supabase
@prisma/orm-family-mongo
@prisma/orm-family-sql
@prisma/orm-framework
@prisma/orm-mongo
@prisma/orm-postgres
@prisma/orm-sqlite
@prisma/orm-target-mongo
@prisma/orm-target-postgres
@prisma/orm-target-sqlite
@prisma/orm-toolchain
commit: |
size-limit report 📦
|
Linked issue
Follow-up to #30051, found during fresh consumer QA. No Linear ticket, per the original project direction.
At a glance
Both fields now admit an explicit null container in Mongo; only the second admits null elements. Previously, omission worked but an explicit null container failed database validation.
Summary
Make Mongo collection validation honor the existing nullable-list contract and generated TypeScript types, independently of element nullability.
Decision
This PR changes all three list-container branches in Mongo BSON schema derivation to emit
bsonType: ['null', 'array']only when the container is nullable. Required containers remain array-only; item schemas and required-field membership remain unchanged. It also corrects the two ADR 248 examples to use the supported.optional()method.Notes for the reviewer
products.embeddingvalidator and its storage hash. Existing historical snapshots are retained.migration-contractfixture remains a valid historical input. Its tests derive their expected hash from that fixture, rather than comparing it with freshly emitted retail-store output; all family tests pass unchanged.origin/mainwasc45a0741fc4fb889b63278cf49fe235aa7ad126f, one commit ahead of the branch base. Its shared-code change adds a PSL diagnostic code; there are no overlapping changed files, andgit merge-tree --write-tree HEAD origin/mainsucceeds. No rebase was performed.How it fits together
Compatibility and upgrade
The new app upgrade fragment directs consumers to re-emit their current contract pair and apply a new validator migration before writing null containers. Applied production migrations and their snapshots must remain unchanged. Runtime deployment alone cannot update collection validators.
The fragment separately describes regeneration for disposable example fixtures. A disposable checkout restored
examples/from actualorigin/main, ranpnpm fixtures:emit, organized the changed migration imports, and reproduced this commit's example files exactly. Example tests were untouched and passed afterward. No extension declaration is needed because no extension code or SPI changed.Testing performed
Finalization checks on the committed content:
pnpm --filter './packages/2-mongo-family/**' test: 2,309 tests across 142 files, including emitter (65) and family (211); all passed.pnpm --filter retail-store test: 55 tests / 13 files passed; localtypecheckandlintpassed. The upgrade rehearsal also passed all 55 tests.pnpm fixtures:check: passed twice with generated output staged; no subsequent fixture drift. Upgrade rehearsal source equality and unchanged-test checks passed.pnpm lint: 102/102 tasks passed after sorting the generated migration imports.pnpm typecheck --continue --concurrency=4: 170/171 tasks passed. Onlyprisma7-adoption#typecheckfailed: the NixOS Prisma 7 schema-engine checksum URL returns 404 Not Found. No checksum or engine-download bypass was used.pnpm lint:deps,lint:code,lint:rules,lint:rules:symlinks,lint:skills,lint:rules:footprint,lint:docs,lint:manifests,lint:workflows,lint:casts,lint:throws,lint:framework-vocabulary,lint:consumer-internal-imports,lint:legacy-name,lint:vitest-timeouts,lint:publishability, andcheck:error-reference: passed.check:upgrade-coverage --mode pr --prev origin/main --head HEADandcheck:release-notes --mode pr --prev origin/main: passed. DCO sign-off and whitespace checks passed.Earlier verification on the same implementation, before accepting the generated fixtures:
pnpm build: 87/87 tasks passed.pnpm --filter integration-tests test test/mongo: 712 reported tests / 112 reported files passed across configured projects. Explicit--project integrationexecution of the new regression passed 56 distinct cases; these counts are not additive.Skill update
No new public API or workflow is introduced: this corrects validation of existing nullability syntax. Consumer action is documented in the independent pending app upgrade fragment; general authoring skills require no change.
Checklist
git commit -s).Alternatives considered
Summary by CodeRabbit
nullas the list value, independently of whether their individual elements may be null.nullor an array of numbers.