fix: only treat @db.Uuid columns as UUIDs — drop field-name inference#39
Conversation
isUuidField inferred UUID from field-name patterns (/^id$/, /_id$/, /_uuid$/, /^uuid$/) for any String column. UUID is a column type, not a naming convention: external text identifiers ending in _id (Stripe acct_/cus_/txn_…, slugs, provider refs) were wrongly given Schema.isUUID() and Die'd at decode. Prisma records real uuid columns via @db.Uuid (bare String → text), so the native-type/@db.Uuid checks already capture every genuine UUID. Removed the name-pattern tier; updated tests + docs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
Disabled knowledge base sources:
📝 WalkthroughWalkthroughUUID detection in ChangesUUID Detection Simplification
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Ports the UUID-detection fix (already merged to
release/nextas #37, published in6.0.0-next.4) to the stablemainline.Problem
isUuidFieldhad a third tier that inferred UUID from the field name (/^id$/,/_id$/,/^.*_uuid$/,/^uuid$/) for anyStringcolumn. UUID is a column type, not a naming convention — the DMMF already knows the type. Every text identifier ending in_id(Stripeacct_/cus_/txn_/…, slugs, provider refs) got a spuriousSchema.String.check(Schema.isUUID())andDied at decode ("Expected a UUID, gotacct_…").Fix
Remove the name tier.
isUuidFieldreturns true only for@db.Uuid(native type or documentation) — which captures 100% of genuine UUID columns. Test + README + CLAUDE updated; changeset added (minor).✅ 347 tests pass, typecheck + build clean.
Summary by CodeRabbit
Bug Fixes
@db.Uuidin Prisma. This removes false positives from field name inference that could cause issues with non-UUID text identifiers.Documentation
@db.Uuidor custom type annotations.