Repository navigation
feat: add coderd_ai_group_budget resource - #453
ssncferreira wants to merge 1 commit into
Conversation
6ad1300 to
e0a507f
Compare
e0a507f to
defcf52
Compare
| // aiGroupBudgetDiag converts an error from the group AI budget API into a | ||
| // diagnostic. The upsert call returns 404 only when the group does not exist, | ||
| // or when the deployment has no group AI budget API. | ||
| func aiGroupBudgetDiag(action string, groupID uuid.UUID, err error) diag.Diagnostics { | ||
| var diags diag.Diagnostics | ||
| if isHTTPNotFound(err) { | ||
| diags.AddError("Group Not Found or Unsupported Coder Version", fmt.Sprintf( | ||
| "Unable to %s AI budget for group %s: the deployment returned 404 for /api/v2/groups/%s/ai/budget. "+ | ||
| "Either the group does not exist, or the deployment is older than Coder version %s, which this resource requires. "+ | ||
| "Original error: %s", | ||
| action, groupID, groupID, aiGroupBudgetMinVersion, err)) | ||
| return diags | ||
| } | ||
| diags.AddError("Client Error", fmt.Sprintf("Unable to %s AI budget for group %s, got error: %s", action, groupID, err)) | ||
| return diags | ||
| } |
There was a problem hiding this comment.
A 404 here doesn't only mean a missing group or an old Coder. Coder also returns 404 when the token can read the group but can't update it: UpsertGroupAIBudget checks update on the group, and the handler maps the denial to 404 through httpapi.Is404Error.
A Template Admin or Auditor token hits this, and so do the organization versions of those roles. Those roles can read groups but can't update them, so the plan-time conflict check passes, then the apply fails with "Group Not Found or Unsupported Coder Version" while the group exists and Coder is new enough.
Could the comment and the message cover the missing permission case too, similar to the 404 message in agentsSystemPromptDiag?
Generated by an agent on behalf of the user
Description
Adds the
coderd_ai_group_budgetresource, which manages the AI spend limit that AI Gateway applies to each member of a group (/api/v2/groups/{group}/ai/budget).coderd_ai_user_budget_overridefollows in #454.Changes
coderd_ai_group_budgetwithgroup_idandspend_limit, registered under the "AI Governance" docs subcategory.spend_limitis in integer micro-units, likecoderd_ai_model_price, and is validated againstcodersdk.MaxAISpendLimitMicrosat plan time.<organization-name>/<group-name>, likecoderd_group.Related to AIGOV-682
Note
Generated by Coder Agents on behalf of @ssncferreira.