-
-
Notifications
You must be signed in to change notification settings - Fork 12
fix: prisma schema generation issue with default() using auth()
#278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning Rate limit exceeded@ymc9 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 0 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughReworks Prisma schema generation to detect and exclude auth() default invocations using new isExpression/isAuthInvocation guards. Renames a helper accordingly. Extends test utilities to optionally write schema.zmodel. Updates an existing regression test structure and adds a new regression test for issue #274 covering auth().id default with relations and migrate. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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 |
|
Claude finished @ymc9's task —— View job Code Review for PR #278Reviewing the fix for Prisma schema generation issue with Analysis Tasks:
SummaryThis PR fixes an issue where Prisma schema generation was incorrectly filtering out Code Quality Assessment✅ Strengths
✅ Implementation DetailsCore Fix (packages/sdk/src/prisma/prisma-schema-generator.ts:264-275): // Before: Generic plugin detection
return AstUtils.streamAst(expr).some((node) =>
isInvocationExpr(node) && this.isFromPlugin(node.function.ref)
);
// After: Specific auth() detection
return AstUtils.streamAst(expr).some((node) =>
isExpression(node) && isAuthInvocation(node)
);Test Enhancement (packages/testtools/src/project.ts:5):
Regression Test (tests/regression/test/issue-274/regression.test.ts):
Security & Performance✅ Security: No concerns identified
✅ Performance: Neutral to positive impact
Potential Issues & Recommendations
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a Prisma schema generation issue where @default() attributes using auth() functions were not being properly handled. The fix ensures that default values using authentication context are excluded from Prisma schema generation since they need to be handled at runtime rather than by Prisma.
- Replaced plugin-based detection with specific
auth()function detection - Added regression test to verify the fix works correctly
- Enhanced test utilities to support schema content injection
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/regression/test/issue-274/regression.test.ts | Adds regression test for auth() default value handling |
| tests/regression/test/issue-204/regression.test.ts | Removes unnecessary describe wrapper from existing test |
| packages/testtools/src/project.ts | Enhances createTestProject to accept optional schema content |
| packages/sdk/src/prisma/prisma-schema-generator.ts | Fixes schema generation to properly handle auth() in default values |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Claude finished @ymc9's task —— View job Code Review for PR #278Reviewing the fix for Prisma schema generation issue with Analysis Tasks:
SummaryThis PR fixes an issue where Prisma schema generation was incorrectly filtering out Code Quality Assessment✅ Strengths
✅ Implementation DetailsCore Fix (packages/sdk/src/prisma/prisma-schema-generator.ts:264-275): // Before: Generic plugin detection
return AstUtils.streamAst(expr).some((node) =>
isInvocationExpr(node) && this.isFromPlugin(node.function.ref)
);
// After: Specific auth() detection
return AstUtils.streamAst(expr).some((node) =>
isExpression(node) && isAuthInvocation(node)
);Test Enhancement (packages/testtools/src/project.ts:5):
Regression Test (tests/regression/test/issue-274/regression.test.ts):
Security & Performance✅ Security: No concerns identified
✅ Performance: Neutral to positive impact
Potential Issues & Recommendations
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/sdk/src/prisma/prisma-schema-generator.ts(5 hunks)packages/testtools/src/project.ts(2 hunks)tests/regression/test/issue-204/regression.test.ts(1 hunks)tests/regression/test/issue-274/regression.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{packages,samples,tests}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place packages only under
packages/,samples/, ortests/
Files:
packages/testtools/src/project.tstests/regression/test/issue-274/regression.test.tspackages/sdk/src/prisma/prisma-schema-generator.tstests/regression/test/issue-204/regression.test.ts
🧬 Code graph analysis (3)
tests/regression/test/issue-274/regression.test.ts (1)
packages/testtools/src/project.ts (1)
createTestProject(5-71)
packages/sdk/src/prisma/prisma-schema-generator.ts (3)
packages/language/src/generated/ast.ts (3)
DataFieldAttribute(348-353)DataFieldAttribute(355-355)isExpression(119-121)packages/language/src/utils.ts (1)
isAuthInvocation(64-66)packages/sdk/src/ts-schema-generator.ts (1)
isAuthInvocation(651-655)
tests/regression/test/issue-204/regression.test.ts (1)
tests/regression/test/issue-204/models.ts (3)
Configuration(11-11)ShirtColor(12-12)ShirtColor(13-13)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: build-test (20.x, sqlite)
|
Claude finished @ymc9's task —— View job Code Review for PR #278Reviewing the fix for Prisma schema generation issue with Analysis Tasks:
SummaryThis PR fixes an issue where Prisma schema generation was incorrectly filtering out Code Quality Assessment✅ Strengths
✅ Implementation DetailsCore Fix (packages/sdk/src/prisma/prisma-schema-generator.ts:272): // Before: Generic plugin detection
return AstUtils.streamAst(expr).some((node) =>
isInvocationExpr(node) && this.isFromPlugin(node.function.ref)
);
// After: Specific auth() detection
return AstUtils.streamAst(expr).some(isAuthInvocation);Test Enhancement (packages/testtools/src/project.ts:5):
Regression Test (tests/regression/test/issue-274/regression.test.ts):
Security & Performance✅ Security: No concerns identified
✅ Performance: Neutral to positive impact
Potential Issues & Recommendations
|
fixes #274
Summary by CodeRabbit