-
-
Notifications
You must be signed in to change notification settings - Fork 19
fix(server): allow Infinity as pageSize option for REST api #581
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
📝 WalkthroughWalkthroughRestApiHandlerOptions.pageSize is updated to accept Infinity as a valid value to disable pagination, alongside positive integers. Validation schema and test coverage are accordingly enhanced. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (4)📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-12-30T15:07:06.254ZApplied to files:
⏰ 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). (4)
🔇 Additional comments (8)
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 Complete ✅Reviewing PR: fix(server): allow Infinity as pageSize option for REST api SummaryThis PR enables the REST API to accept ✅ StrengthsCode Quality & Best Practices
Test Coverage
Implementation Quality
📋 Technical AnalysisCode Changes (line-by-line)packages/server/src/api/rest/index.ts:295 - pageSize: z.number().positive().optional(),
+ pageSize: z.union([z.number().int().positive(), z.literal(Infinity)]).optional(),✅ Excellent:
Runtime Behavior AnalysisPagination Logic (lines 1779-1783) let pageSizeOption = this.options.pageSize ?? DEFAULT_PAGE_SIZE;
if (pageSizeOption <= 0) {
pageSizeOption = DEFAULT_PAGE_SIZE;
}
Collection Read Logic (lines 869-904) if (limit === Infinity) {
const entities = await (client as any)[type].findMany(args);
// ... no pagination logic
} else {
args.take = limit;
// ... pagination logic with count query
}✅ Perfect: Clean branching that avoids expensive count queries when pagination is disabled. 🛡️ Security Considerations✅ No security concerns identified:
⚡ Performance Implications✅ Performance improvements:
🐛 Potential IssuesMinor Issue: Query Parameter HandlingIn Documentation ConsiderationThe JSDoc comment for 🎯 RecommendationsEnhancement Suggestions
Test Coverage Suggestions✅ Current coverage is excellent. The tests cover:
🎉 Overall AssessmentThis is a high-quality implementation that:
Approval Recommendation: ✅ APPROVE This change is production-ready and adds valuable functionality without introducing risks. |
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 the REST API validation to allow Infinity as a valid pageSize option, enabling users to disable pagination as documented in the API comments.
- Updated Zod validation schema to accept either positive integers or the literal value
Infinity - Added comprehensive test coverage for edge cases (Infinity, decimals, NaN)
- Removed workaround in existing test that previously used a large number instead of Infinity
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/server/src/api/rest/index.ts | Updated pageSize validation schema to accept Infinity literal alongside positive integers |
| packages/server/test/api/options-validation.test.ts | Added tests for Infinity, decimal, and NaN pageSize values; updated existing test to use Infinity instead of workaround |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.