Skip to content

feat(api): split entitlement access check contract - #5208

Merged
turip merged 1 commit into
feat/v3-customer-entitlement-valuefrom
feat/v3-entitlement-access-check-contract
Sep 25, 2026
Merged

turip merged 1 commit into
feat/v3-customer-entitlement-valuefrom
feat/v3-entitlement-access-check-contract

Conversation

@turip

@turip turip commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Remove the expand query parameter from the customer feature access check.
  • Give the check its own result model, with an optional entitlement type for features without an entitlement.
  • Keep the entitlement value endpoint and access list on the value result model, and regenerate the v3 OpenAPI and SDK artifacts.

Scope

This PR changes the AIP contract and generated artifacts. Handler and service implementation changes will follow separately. The generated Go server interface now differs from the existing handler, so the root API build may fail until that follow-up lands.

Verification

  • v3 AIP TypeSpec generation
  • v3 OpenAPI bundling and Go API generation
  • make test-go-sdk
  • JavaScript SDK typecheck

Stacked on #5149.

RetriggerConfidence Score: 2/5

The PR is not ready to merge because the existing server and e2e code still do not compile against the generated contract.

Fix All in Claude CodeFindings

  1. P1 Generated interface breaks server build ▶
  2. P1 SDK change breaks e2e compilation ▶
  3. P1 Missing entitlements get synthetic type ▶
Fix with agent prompt
### Issue 1
api/v3/api.gen.go:undefined-14717
The generated access-check method no longer takes params, but `api/v3/server/routes.go:94` still takes the removed `api.GetCustomerEntitlementAccessParams` type. The method therefore cannot satisfy `ServerInterface`, and the root Go build fails. The access handlers also still reference the removed `BillingEntitlementAccessResult` type; they need to be updated alongside the generated contract.

### Issue 2
api/v3/client/entitlements.go:undefined-99
`GetCustomerAccess` no longer accepts a fourth argument, and `GetCustomerEntitlementAccessParams` has been removed. The access, reset, and history e2e tests still pass that type, so the e2e module cannot compile. The plan-entitlement test also names the removed `EntitlementAccessResult`; these callers need to use the split check and value contracts.

### Issue 3
api/spec/packages/aip/src/entitlements/access.tsp:undefined-62
The new check contract leaves `type` absent when a feature has no entitlement, but the existing converter assigns `static` in that case. Once the handler is adapted to the new result model, an access check for a feature without an entitlement will report a static entitlement unless the mapping changes too.

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!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR separates the single-feature access check from the entitlement value contract and regenerates the v3 OpenAPI and SDK artifacts.

  • The access check no longer accepts expand and returns a smaller result with an optional entitlement type.
  • The entitlement value endpoint and access list retain the value result model.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Customer feature access check] --> B[EntitlementAccessCheckResult]
  C[Entitlement value endpoint] --> D[EntitlementValueResult]
  E[Customer access list] --> D
Loading

Reviews (2) · Last reviewed commit: "feat(api): split entitlement access chec..."

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository: openmeterio/openmeter/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 4d04a9fb-1c21-42af-8511-f704829cd0a2

📥 Commits

Reviewing files that changed from the base of the PR and between 19adcd4 and 901c237.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (10)
  • api/spec/packages/aip-client-javascript/src/funcs/entitlements.ts
  • api/spec/packages/aip-client-javascript/src/index.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/entitlements.ts
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • api/spec/packages/aip/src/entitlements/access.tsp
  • api/spec/packages/aip/src/entitlements/operations.tsp
  • api/v3/api.gen.go
  • api/v3/client/entitlements.go
  • api/v3/client/models_entitlements.go
 _________________________________________
< Time zones: the final boss of software. >
 -----------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

Comment thread api/v3/api.gen.go
@@ -14461,7 +14466,7 @@ type ServerInterface interface {
ListCustomerEntitlementAccess(w http.ResponseWriter, r *http.Request, customerId ULID)
// Get customer entitlement access
// (GET /openmeter/customers/{customerId}/entitlement-access/features/{featureKey})
GetCustomerEntitlementAccess(w http.ResponseWriter, r *http.Request, customerId ULID, featureKey ResourceKey, params GetCustomerEntitlementAccessParams)
GetCustomerEntitlementAccess(w http.ResponseWriter, r *http.Request, customerId ULID, featureKey ResourceKey)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Generated interface breaks server build

The generated access-check method no longer takes params, but api/v3/server/routes.go:94 still takes the removed api.GetCustomerEntitlementAccessParams type. The method therefore cannot satisfy ServerInterface, and the root Go build fails. The access handlers also still reference the removed BillingEntitlementAccessResult type; they need to be updated alongside the generated contract.

Prompt To Fix With AI
This is a comment left during a code review.
Path: api/v3/api.gen.go
Line: 14469

Comment:
**Generated interface breaks server build**

The generated access-check method no longer takes params, but `api/v3/server/routes.go:94` still takes the removed `api.GetCustomerEntitlementAccessParams` type. The method therefore cannot satisfy `ServerInterface`, and the root Go build fails. The access handlers also still reference the removed `BillingEntitlementAccessResult` type; they need to be updated alongside the generated contract.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex


// Get the customer's access to a single feature.
func (s *EntitlementsService) GetCustomerAccess(ctx context.Context, customerID string, featureKey string, params GetCustomerEntitlementAccessParams) (*EntitlementAccessResult, error) {
func (s *EntitlementsService) GetCustomerAccess(ctx context.Context, customerID string, featureKey string) (*EntitlementAccessCheckResult, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 SDK change breaks e2e compilation

GetCustomerAccess no longer accepts a fourth argument, and GetCustomerEntitlementAccessParams has been removed. The access, reset, and history e2e tests still pass that type, so the e2e module cannot compile. The plan-entitlement test also names the removed EntitlementAccessResult; these callers need to use the split check and value contracts.

Prompt To Fix With AI
This is a comment left during a code review.
Path: api/v3/client/entitlements.go
Line: 64

Comment:
**SDK change breaks e2e compilation**

`GetCustomerAccess` no longer accepts a fourth argument, and `GetCustomerEntitlementAccessParams` has been removed. The access, reset, and history e2e tests still pass that type, so the e2e module cannot compile. The plan-entitlement test also names the removed `EntitlementAccessResult`; these callers need to use the split check and value contracts.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

* If not provided, the feature has no entitlement defined (has access is always false in this case)
*/
@visibility(Lifecycle.Read)
type?: EntitlementType;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Missing entitlements get synthetic type

The new check contract leaves type absent when a feature has no entitlement, but the existing converter assigns static in that case. Once the handler is adapted to the new result model, an access check for a feature without an entitlement will report a static entitlement unless the mapping changes too.

Prompt To Fix With AI
This is a comment left during a code review.
Path: api/spec/packages/aip/src/entitlements/access.tsp
Line: 62

Comment:
**Missing entitlements get synthetic type**

The new check contract leaves `type` absent when a feature has no entitlement, but the existing converter assigns `static` in that case. Once the handler is adapted to the new result model, an access check for a feature without an entitlement will report a static entitlement unless the mapping changes too.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

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!

Fix in Claude Code Fix in Codex

@borosr
borosr force-pushed the feat/v3-customer-entitlement-value branch 3 times, most recently from 1df2a19 to 19adcd4 Compare September 25, 2026 11:24
@turip
turip force-pushed the feat/v3-entitlement-access-check-contract branch from 0a06716 to 3c304c7 Compare September 25, 2026 11:39
@turip
turip force-pushed the feat/v3-entitlement-access-check-contract branch from 3c304c7 to 901c237 Compare September 25, 2026 11:44
@turip
turip marked this pull request as ready for review September 25, 2026 11:45
@turip
turip requested a review from a team as a code owner September 25, 2026 11:45
@turip
turip merged commit dd1aa9c into feat/v3-customer-entitlement-value Sep 25, 2026
20 of 31 checks passed
@turip
turip deleted the feat/v3-entitlement-access-check-contract branch September 25, 2026 11:46
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.

1 participant