You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(credits): filter grants by feature spendability - #5317
Credit grant listing can now select grants spendable on requested features, including grants without feature restrictions. Matching applies before pagination.
filter[feature_key][oeq]=api-calls,storage matches either feature without duplicating shared grants.
Shorthand and eq select one feature; exists=false selects grants without feature restrictions.
Lifecycle status remains a separate filter.
Reuses the balance/history feature-matching SQL predicates and regenerates the v3 API and SDKs.
Validation: HTTP filter tests, PostgreSQL-backed credit-grant and ledger tests, Go SDK build/vet/tests, TypeScript SDK typecheck, and scoped Go lint.
Summary by CodeRabbit
New Features
Added feature_key filtering when listing credit grants.
Supports exact matching, matching any of multiple feature keys, and selecting grants without feature restrictions.
Feature filtering works with pagination and includes unrestricted grants when no filter is provided.
Bug Fixes
Invalid or conflicting feature filters now return a clear bad-request response.
Confidence Score: 5/5
The PR appears safe to merge, with no outstanding findings.
Summary
Adds feature_key filtering to credit grant lists, including grants without feature restrictions.
Credit grant lists can find grants usable for selected features.
🚧 Files skipped from review as they are similar to previous changes: 1
openmeter/billing/charges/README.md
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
📝 Walkthrough
Credit-grant listing now accepts an optional feature-key filter. The handler validates and passes the filter to the listing service, which applies feature predicates to charge queries. Tests cover supported and invalid filters, unrestricted grants, totals, and pagination.
Changes: Credit grant feature filtering
Layer / File(s)
Summary
API contract and request parsing api/spec/packages/aip/..., api/spec/packages/aip-client-javascript/src/models/*, api/v3/api.gen.go, api/v3/client/customers_credits_grants.go, api/v3/handlers/customers/credits/*
The API specifications and clients add the feature_key filter. The handler validates supported operators and passes valid filters to the listing request. Invalid filters return HTTP 400.
Filter propagation and grant selection openmeter/billing/creditgrant/*, openmeter/billing/charges/creditpurchase/*, openmeter/ledger/creditfilterquery/*, openmeter/ledger/account/adapter/subaccount.go, openmeter/ledger/historical/adapter/*, openmeter/ledger/internal/routequery/subaccount_ids.go, openmeter/billing/charges/README.md, test/credits/creditgrant_test.go
The listing service and charge adapter validate and propagate feature filters. Charge queries combine exact-feature and match-feature predicates. Ledger predicate references use creditfilterquery. Tests cover matching, unrestricted grants, totals, and pagination.
Tracing rethrows production panicspkg/framework/tracex/v2/span.go:94▶
The new tracing helper calls panic(r) in production code. The repository guide says, “Never use panic in non-test code. Return and propagate errors.” Recording the callback failure does not satisfy that requirement while the helper still rethrows it.
Return the failure through the helper’s error result instead. This repository requirement must be satisfied before merging.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Credit grant listing can now select grants spendable on requested features, including grants without feature restrictions. Matching applies before pagination.
filter[feature_key][oeq]=api-calls,storagematches either feature without duplicating shared grants.eqselect one feature;exists=falseselects grants without feature restrictions.Reuses the balance/history feature-matching SQL predicates and regenerates the v3 API and SDKs.
Validation: HTTP filter tests, PostgreSQL-backed credit-grant and ledger tests, Go SDK build/vet/tests, TypeScript SDK typecheck, and scoped Go lint.
Summary by CodeRabbit
New Features
feature_keyfiltering when listing credit grants.Bug Fixes


Confidence Score: 5/5
The PR appears safe to merge, with no outstanding findings.Summary
Adds
feature_keyfiltering to credit grant lists, including grants without feature restrictions.Reviews (3) · Last reviewed commit: "chore(ci): retrigger pull request checks" · Reviewed by Greptile