Skip to content

fix(api): default the missing page parameter on v1 grant and customer override lists - #5591

Merged
gergely-kurucz-konghq merged 1 commit into
mainfrom
fix/v1-page-default
Nov 19, 2026
Merged

gergely-kurucz-konghq merged 1 commit into
mainfrom
fix/v1-page-default

Conversation

@gergely-kurucz-konghq

@gergely-kurucz-konghq gergely-kurucz-konghq commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Overview

What

  • GET /api/v1/grants and GET /api/v1/billing/customers default the missing page parameter when a client sends only one of page and pageSize. page defaults to 1, pageSize to 100.
  • Requests without either parameter behave as before:
    • grants keep the plain array response with limit/offset;
    • customer overrides keep listing every override.

Why

  • With pageSize set and page missing, the handlers passed a page number of 0. Page.Offset() (size * (number - 1)) became negative, Postgres rejected it (OFFSET must not be negative), and the request failed with 500.
  • With page set and pageSize missing, the page size was 0, so the list came back empty.
  • Production logs show the 500 on both endpoints, always with pageSize and without page.
  • The entitlement and feature lists already default the missing parameter this way.

How

  • openmeter/credit/driver/grant.go and openmeter/billing/httpdriver/customeroverride.go: when Page is not zero, fill in a zero page number or page size with commonhttp.DefaultPage and commonhttp.DefaultPageSize.
  • New handler tests, grant_test.go and customeroverride_test.go, check the page that reaches the repository or service when neither, one, or both parameters are set.

Notes for reviewer

  • The other v1 list handlers already default both parameters.
  • Verified: the new tests fail without the fix and pass with it, and make lint-go-fast passes on both packages.
  • Untracked design documents and local files are excluded.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

Defaults the missing pagination value on the v1 grant and customer override lists while preserving requests that omit both values.

  • Grant lists fill in a missing page setting when the other is supplied.
  • Customer override lists fill in a missing page setting when the other is supplied.

No actionable issues found. Tests were not run during this review.

Reviews (1) · Last reviewed commit: "fix(api): default the missing page param..." · Reviewed by Greptile

Summary by CodeRabbit

  • Bug Fixes
    • Improved pagination defaults for customer overrides and grants: when either page number or page size is provided, the missing value now receives a default. Requests without pagination parameters remain unchanged.

… override lists

GET /api/v1/grants and GET /api/v1/billing/customers passed a page number
of 0 to the adapter when a client set pageSize without page. The page
offset became negative, Postgres rejected it, and the request failed
with 500.

When only one of page and pageSize is set, default the other one, as the
entitlement and feature lists already do. Requests without either
parameter keep their unpaged behavior.
@gergely-kurucz-konghq
gergely-kurucz-konghq requested a review from a team as a code owner November 19, 2026 14:38
@gergely-kurucz-konghq gergely-kurucz-konghq added the release-note/bug-fix Release note: Bug Fixes label Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ListCustomerOverrides and ListGrants now default missing pagination values when either page parameter is set. Both handlers leave pagination unchanged when neither parameter is set. Tests cover all four parameter combinations for each handler.

Changes: List pagination

Layer / File(s) Summary
Default pagination in list handlers
openmeter/billing/httpdriver/customeroverride.go, openmeter/billing/httpdriver/customeroverride_test.go, openmeter/credit/driver/grant.go, openmeter/credit/driver/grant_test.go
Both handlers default a missing page number or page size when either pagination parameter is supplied. Tests cover absent, partial, and complete pagination values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: chrisgacsal, galexihu, borosr

Merge Risk: Minimal · up to 2b17f

Requests that supply only one of page or pageSize now get a default for the missing value instead of a negative offset or an empty list. Requests with neither parameter behave as before. No actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two endpoints that change (v1 grant and customer override lists) and the core fix (defaulting the missing page parameter). The raw summary confirms that both list handlers now defa…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two endpoints that change (v1 grant and customer override lists) and the core fix (defaulting the missing page parameter). The raw summary confirms that both list handlers now default a zero page or page size when only one parameter is set, so the title matches the main change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 55759ef and 2b17fb5.

Files selected for processing: 4

  • openmeter/billing/httpdriver/customeroverride.go
  • openmeter/billing/httpdriver/customeroverride_test.go
  • openmeter/credit/driver/grant.go
  • openmeter/credit/driver/grant_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@gergely-kurucz-konghq
gergely-kurucz-konghq merged commit 3fb0718 into main Nov 19, 2026
33 of 35 checks passed
@gergely-kurucz-konghq
gergely-kurucz-konghq deleted the fix/v1-page-default branch November 19, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants