Skip to content

Conversation

@whoAbhishekSah
Copy link
Member

Summary

Simplify billing entitlement and usage APIs by automatically inferring billing_id from org_id. Clients now only need to provide org_id when calling these RPCs.

Changes

Proto Updates

  • Deprecated billing_id and project_id fields in:
    • CheckFeatureEntitlementRequest
    • CreateBillingUsageRequest
    • RevertBillingUsageRequest
  • Updated proton ref to 4144445eb0f9cbd1a801a3d0aa5cfce4cc0ea551

Backend Updates

All handlers now always fetch billing_id from org_id:

  • CheckFeatureEntitlement: Uses customerService.GetByOrgID()
  • CreateBillingUsage: Uses customerService.GetByOrgID()
  • RevertBillingUsage: Uses customerService.GetByOrgID()

Removed ensureBillingAccountBelongToOrg validation from CreateBillingUsage authorization interceptor (now redundant).

Error Handling

  • ErrNotFound: Empty response for CheckFeatureEntitlement, CodeNotFound for others
  • ErrInvalidUUID/ErrInvalidID: CodeInvalidArgument
  • Other errors: CodeInternal with logging

Benefits

  • Simpler API: Single required parameter (org_id)
  • More secure: Users cannot provide arbitrary billing_id
  • Consistent: Same behavior across all requests
  • Cleaner code: No conditional logic for inferring billing_id

Breaking Changes

None - deprecated fields are still accepted for backward compatibility but ignored.

whoAbhishekSah and others added 2 commits December 3, 2025 13:45
Update PROTON_COMMIT to 4144445eb0f9cbd1a801a3d0aa5cfce4cc0ea551
which deprecates billing_id and project_id in entitlement and usage RPCs.

Generated files updated:
- proto/v1beta1/admin.pb.go
- proto/v1beta1/frontier.pb.go
- proto/apidocs.swagger.yaml

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…e handlers

Update handlers to always fetch billing_id from org_id, ignoring deprecated
billing_id parameter completely:
- CheckFeatureEntitlement: always use customerService.GetByOrgID()
- CreateBillingUsage: always use customerService.GetByOrgID()
- RevertBillingUsage: always use customerService.GetByOrgID()

Remove billing_id validation from CreateBillingUsage authorization interceptor
since billing_id is now always inferred in the handler.

Error handling for GetByOrgID:
- ErrNotFound: Return empty response for CheckFeatureEntitlement, CodeNotFound for others
- ErrInvalidUUID, ErrInvalidID: Return CodeInvalidArgument
- Other errors: Return CodeInternal with logging

Benefits:
- Simpler code with single path (no conditional logic)
- More secure (users cannot provide arbitrary billing_ids)
- Consistent behavior across all requests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@vercel
Copy link

vercel bot commented Dec 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
frontier Ready Ready Preview Comment Dec 4, 2025 5:01am

Update tests to work with new implementation that always infers billing_id from org_id:

CheckFeatureEntitlement tests:
- Add customerService mock with GetByOrgID expectations
- Change requests to use org_id instead of billing_id
- Add test for ErrNotFound (returns empty response)
- Add test for ErrInvalidUUID (returns invalid argument)

CreateBillingUsage tests:
- Add customerService mock with GetByOrgID expectations
- Change all requests to use org_id instead of billing_id
- All existing test cases now pass with customerService mocking

All tests pass successfully.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coveralls
Copy link

coveralls commented Dec 4, 2025

Pull Request Test Coverage Report for Build 19918211554

Details

  • 18 of 45 (40.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 37.645%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/api/v1beta1connect/billing_check.go 12 15 80.0%
internal/api/v1beta1connect/billing_usage.go 6 30 20.0%
Totals Coverage Status
Change from base Build 19819539745: 0.001%
Covered Lines: 15705
Relevant Lines: 41719

💛 - Coveralls

Clean up struct field alignment and formatting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@whoAbhishekSah whoAbhishekSah changed the title reafctor(billing): Billing simplification entitlement usage refactor(billing): Billing simplification entitlement usage Dec 5, 2025
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.

3 participants