Skip to content

allow large pagesize limits on rest api#2661

Open
sw34 wants to merge 2 commits intozenstackhq:release/v2from
sw34:fix-rest-limit-over-100
Open

allow large pagesize limits on rest api#2661
sw34 wants to merge 2 commits intozenstackhq:release/v2from
sw34:fix-rest-limit-over-100

Conversation

@sw34
Copy link
Copy Markdown
Contributor

@sw34 sw34 commented May 8, 2026

resolves #2660

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f5140d7d-83ca-4581-9867-0fad516ae83f

📥 Commits

Reviewing files that changed from the base of the PR and between a1f947b and 17e5a6f.

📒 Files selected for processing (2)
  • packages/server/src/api/rest/index.ts
  • packages/server/tests/api/rest-largepagesize.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/server/src/api/rest/index.ts
  • packages/server/tests/api/rest-largepagesize.test.ts

📝 Walkthrough

Walkthrough

This PR changes REST pagination so getPagination() only clamps a parsed positive page[limit] when options.pageSize is explicitly provided; otherwise the client-supplied positive limit is honored. It adds tests seeding 150 users and asserting responses for page[limit]=15 and page[limit]=125 return 15 and 125 items respectively.

Changes

REST Pagination Size Limit

Layer / File(s) Summary
Pagination Clamping Logic
packages/server/src/api/rest/index.ts
getPagination() removes unconditional clamping to DEFAULT_PAGE_SIZE. The limit is now clamped only when options.pageSize is explicitly provided, permitting client-specified positive limits when no maximum is configured.
Test Setup
packages/server/tests/api/rest-largepagesize.test.ts
Adds per-test DB reset, loads a temporary Prisma schema and generated metadata, and builds a REST handler wrapper for tests.
Pagination Test: limit=15
packages/server/tests/api/rest-largepagesize.test.ts
Seeds 150 users and asserts that requesting page[limit]=15 returns 15 items (meta/link assertions commented out).
Pagination Test: limit=125
packages/server/tests/api/rest-largepagesize.test.ts
Seeds 150 users and asserts that requesting page[limit]=125 returns 125 items (meta/link assertions commented out).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'allow large pagesize limits on rest api' directly reflects the main change: modifying REST API pagination to allow larger page size limits.
Description check ✅ Passed The description 'resolves #2660' is related to the changeset, indicating this PR addresses the reported bug about pageSize limits.
Linked Issues check ✅ Passed The PR changes precisely match issue #2660 requirements: the code modification applies pageSize limit only when options.pageSize is explicitly set, not by default.
Out of Scope Changes check ✅ Passed All changes are in-scope: REST API pagination logic modification and new test suite validating the fix for large pageSize limits.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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/server/src/api/rest/index.ts`:
- Around line 1675-1677: The clamp currently uses the raw this.options.pageSize
which can be invalid; change it to use the normalized pageSizeOption (and only
apply the clamp if pageSizeOption !== undefined) so that limit =
Math.min(pageSizeOption, limit) is used instead of referencing
this.options.pageSize, ensuring negative or invalid raw values don't produce a
negative limit; update the block around where limit and pageSizeOption are
handled in the same function to perform the explicit !== undefined check before
clamping.

In `@packages/server/tests/api/rest-largepagesize.test.ts`:
- Line 41: The test title string "returns only 15 items when limit set to 5" is
inconsistent with the request using page[limit]=15; update the Jest/Mocha
it(...) description to reflect the actual behavior (e.g., change to "returns
only 15 items when limit set to 15") so the test name matches the request in the
test body that uses page[limit]=15 in the rest-largepagesize.test spec.
🪄 Autofix (Beta)

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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 50a35ab3-7a39-426a-889f-b68a8e71ef1a

📥 Commits

Reviewing files that changed from the base of the PR and between 7634e2c and a1f947b.

📒 Files selected for processing (2)
  • packages/server/src/api/rest/index.ts
  • packages/server/tests/api/rest-largepagesize.test.ts

Comment thread packages/server/src/api/rest/index.ts Outdated
Comment thread packages/server/tests/api/rest-largepagesize.test.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant