fix(api): attribute v2 workspace keys to billing actor - #6376
fix(api): attribute v2 workspace keys to billing actor#6376TheodoreSpeaks wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview Across v2 routes, handlers distinguish who may act ( Infrastructure: Reviewed by Cursor Bugbot for commit 622ccb8. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThe PR separates workspace-key authorization from billing attribution, preserving the key creator as the authorization principal while using the workspace billing actor for quotas, audits, and persisted operations.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/v1/middleware.ts | Introduces the workspace-key principal/actor split and enforces the creator's effective workspace permission during authorization. |
| apps/sim/app/api/public-api-route-handler.ts | Applies organization-aware v2 gating and propagates API-key identity through request context. |
| apps/sim/app/api/v2/workflows/[id]/execute/route.ts | Authorizes workflow execution as the key creator while preserving the billing actor and attribution snapshot through execution. |
| apps/sim/app/api/v2/secrets/[name]/route.ts | Uses the creator for secret authorization, attributes workspace writes to the billing actor, and rejects personal-secret access from workspace keys. |
| apps/sim/app/api/v2/knowledge/[id]/documents/uploads/utils.ts | Restores multipart billing attribution from session metadata so completion retries retain the admission-time payer. |
| apps/sim/lib/table/orchestration/import-resource.ts | Carries frozen billing attribution through table-import orchestration. |
Sequence Diagram
sequenceDiagram
participant Client
participant Auth as V2 API Authentication
participant Authz as Workspace Authorization
participant Billing as Billing and Quotas
participant Operation as Route or Background Operation
Client->>Auth: Request with workspace API key
Auth->>Auth: Resolve key creator and current permission
Auth->>Billing: Resolve workspace billing actor and payer snapshot
Auth-->>Authz: Creator principal and frozen permission
Auth-->>Operation: Billing actor and attribution snapshot
Authz->>Authz: Enforce creator permission
Billing->>Billing: Apply payer quota and billing status
Operation->>Operation: Persist or execute with frozen attribution
Reviews (2): Last reviewed commit: "fix(api): preserve workspace key permiss..." | Re-trigger Greptile
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 622ccb8. Configure here.
Summary
Type of Change
Testing
Checklist