mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: ai cost control cap configurable AI spend limit (#27640)
## Problem A configured AI spend limit was only validated as `gte=0`, with no upper bound. The group spend query multiplies the per-member limit by the number of attributed members, so a large enough limit overflows `bigint` and fails the whole query, returning an error for every group in the request rather than just the misconfigured one. ## Changes - Add `MaxAISpendLimitMicros`, $1,000,000 per member per budget period. - Reject group budgets and per-user overrides above the maximum with a 400 naming the limit. - Bound both budget forms in the UI so they show the valid range before submitting. Follow-up https://github.com/coder/coder/pull/27589#discussion_r3668956350 Depends on https://github.com/coder/coder/pull/27589 > [!NOTE] > Initially generated by Claude Opus 5, modified and reviewed by @ssncferreira
This commit is contained in:
Generated
+2
@@ -26320,6 +26320,7 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"spend_limit_micros": {
|
||||
"description": "SpendLimitMicros must not exceed MaxAISpendLimitMicros.",
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
}
|
||||
@@ -26337,6 +26338,7 @@ const docTemplate = `{
|
||||
"format": "uuid"
|
||||
},
|
||||
"spend_limit_micros": {
|
||||
"description": "SpendLimitMicros must not exceed MaxAISpendLimitMicros.",
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
}
|
||||
|
||||
Generated
+2
@@ -24200,6 +24200,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"spend_limit_micros": {
|
||||
"description": "SpendLimitMicros must not exceed MaxAISpendLimitMicros.",
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
}
|
||||
@@ -24215,6 +24216,7 @@
|
||||
"format": "uuid"
|
||||
},
|
||||
"spend_limit_micros": {
|
||||
"description": "SpendLimitMicros must not exceed MaxAISpendLimitMicros.",
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user