Skip to content

fix(api): bound v1 list endpoints with a page size (EN-1230) - #193

Closed
flemzord wants to merge 1 commit into
mainfrom
fix/v1-list-pagination
Closed

fix(api): bound v1 list endpoints with a page size (EN-1230)#193
flemzord wants to merge 1 commit into
mainfrom
fix/v1-list-pagination

Conversation

@flemzord

Copy link
Copy Markdown
Member

Problem (H11 — HIGH)

v1 listInstances and listWorkflows passed a zero-value paginated query. In go-libs bunpaginate, PageSize == 0 applies no LIMIT, so each request loaded the entire workflow_instances / workflows table into memory and serialized it — an unbounded query on tables that grow without limit in production.

Fix

Read the page size with bunpaginate.GetPageSize (default 15, max 100, overridable via ?pageSize=), exactly as the v2 handlers do, while keeping the v1 flat-array response shape.

Behavioural note: v1 list responses are now bounded to one page (default 15); clients needing more pass ?pageSize= (up to 100). v1 has no cursor envelope, so this is the pragmatic bound for the legacy surface.

Test

TestListInstancesIsBounded: 20 instances ⇒ default returns 15, ?pageSize=5 returns 5.

Severity: HIGH.

The v1 listInstances and listWorkflows handlers passed a zero-value query,
and bunpaginate applies no LIMIT when PageSize == 0 -- so each request
loaded the entire workflow_instances / workflows table into memory.

Read the page size via bunpaginate.GetPageSize (default 15, max 100,
overridable with ?pageSize=), as the v2 handlers already do, while keeping
the v1 flat-array response shape.

Behavioural note: v1 list responses are now bounded to one page; clients
needing more pass ?pageSize=. Adds TestListInstancesIsBounded.
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@flemzord, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 58 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b28af36c-2bf4-4aa4-8c29-cd87847b3d2c

📥 Commits

Reviewing files that changed from the base of the PR and between 271bf8d and 62d2eb0.

📒 Files selected for processing (3)
  • internal/api/v1/handler_list_instances.go
  • internal/api/v1/handler_list_instances_test.go
  • internal/api/v1/handler_list_workflows.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/v1-list-pagination

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.

@flemzord

flemzord commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

Tracked in Jira: EN-1230 (Epic EN-1217).

@flemzord flemzord changed the title fix(api): bound v1 list endpoints with a page size fix(api): bound v1 list endpoints with a page size (EN-1230) Jun 11, 2026
return func(w http.ResponseWriter, r *http.Request) {

workflows, err := backend.ListWorkflows(r.Context(), bunpaginate.OffsetPaginatedQuery[any]{})
// Bound the query: without a page size, bunpaginate applies no LIMIT,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This PR applies the v2 pagination pattern to /v1/workflows and /v1/instances, but /v1/triggers/{triggerID}/occurrences still builds ListTriggersOccurrencesQuery without PageSize, while the v2 handler already calls bunpaginate.GetPageSize. Since this fix is meant to bound the v1 list endpoints, please include the occurrences handler too; otherwise that endpoint still runs with PageSize == 0 and no LIMIT.

@flemzord

flemzord commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

Superseded by #199, which consolidates this change with the related reliability and safety fixes on top of the current main branch.

@flemzord flemzord closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant