Repository navigation
fix(api): default the missing page parameter on v1 grant and customer override lists - #5591
Conversation
… 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.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Overview
What
GET /api/v1/grantsandGET /api/v1/billing/customersdefault the missing page parameter when a client sends only one ofpageandpageSize.pagedefaults to 1,pageSizeto 100.limit/offset;Why
pageSizeset andpagemissing, 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.pageset andpageSizemissing, the page size was 0, so the list came back empty.pageSizeand withoutpage.How
openmeter/credit/driver/grant.goandopenmeter/billing/httpdriver/customeroverride.go: whenPageis not zero, fill in a zero page number or page size withcommonhttp.DefaultPageandcommonhttp.DefaultPageSize.grant_test.goandcustomeroverride_test.go, check the page that reaches the repository or service when neither, one, or both parameters are set.Notes for reviewer
make lint-go-fastpasses on both packages.

Confidence 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.
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