Skip to content

fix: correct pagination skip increment in ListAllProjects and ListAllTemplates#212

Merged
yuaanlin merged 1 commit intozeabur:mainfrom
eliajhmauve:fix/pagination-skip-limit-mismatch
Apr 3, 2026
Merged

fix: correct pagination skip increment in ListAllProjects and ListAllTemplates#212
yuaanlin merged 1 commit intozeabur:mainfrom
eliajhmauve:fix/pagination-skip-limit-mismatch

Conversation

@eliajhmauve
Copy link
Copy Markdown
Contributor

@eliajhmauve eliajhmauve commented Mar 30, 2026

Problem

Both ListAllProjects and ListAllTemplates use skip += 5 while requesting limit=100 items per page:

// pkg/api/project.go
projectCon, err := c.ListProjects(context.Background(), skip, 100)
// ...
skip += 5   // ← should be 100
// pkg/api/template.go
templateCon, err := c.ListTemplates(context.Background(), skip, 100)
// ...
skip += 5   // ← should be 100

This means:

  • Page 1: fetches items 0–99 ✅
  • Page 2: fetches items 5–104 ❌ (95 duplicates, misses items 100–104)
  • Page 3: fetches items 10–109 ❌
  • ...

Any user with more than 5 projects or templates gets heavily duplicated results, and items beyond position 5 on the second page are never returned.

Fix

Change skip += 5 to skip += 100 in both functions so the offset advances by the actual page size.

Files changed

  • pkg/api/project.go — 1-line fix
  • pkg/api/template.go — 1-line fix

Summary by CodeRabbit

  • Chores
    • Optimized pagination for projects and templates retrieval to improve API efficiency.

…Templates

Both functions request 100 items per page (limit=100) but advance
the skip cursor by only 5 on each iteration:

  skip += 5  // should be skip += 100

This means pages 2+ always start at offset 5, 10, 15... instead of
100, 200, 300... causing the first 5 results to be fetched ~20 times
and results 6-100 to never be returned on subsequent pages.

Any user with more than 5 projects or templates would receive duplicate
and incomplete results.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 255fcdd2-1f9c-4f35-9876-a0f299dbc979

📥 Commits

Reviewing files that changed from the base of the PR and between 76b8768 and f1eadac.

📒 Files selected for processing (2)
  • pkg/api/project.go
  • pkg/api/template.go

Walkthrough

Two pagination functions have their step size increments updated from 5 to 100. The ListAllProjects and ListAllTemplates functions now advance through result pages with larger offsets per iteration while maintaining their termination conditions.

Changes

Cohort / File(s) Summary
Pagination Step Size Update
pkg/api/project.go, pkg/api/template.go
Updated pagination loop increment from +5 to +100 in list functions, reducing iterations needed to paginate through results while preserving per-request limits and termination logic.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: fixing pagination skip increment values in two functions from 5 to 100 to match the API limit parameter.
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

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.

@yuaanlin yuaanlin merged commit 2664b25 into zeabur:main Apr 3, 2026
5 checks passed
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.

3 participants