fix(terraform): omit empty key team updates

This commit is contained in:
Erik Bogado 2026-09-07 03:41:11 -03:00
parent 168a0055a2
commit 9ed1ca3399
2 changed files with 4 additions and 2 deletions

View file

@ -79,7 +79,6 @@ func (c *Client) UpdateKey(key *Key) (*Key, error) {
// Create a new map with only the fields that can be updated
updateData := map[string]interface{}{
"key": key.Key,
"team_id": key.TeamID,
"metadata": key.Metadata,
"key_alias": key.KeyAlias,
"aliases": key.Aliases,
@ -92,6 +91,9 @@ func (c *Client) UpdateKey(key *Key) (*Key, error) {
// The proxy rejects an empty-string budget_duration with a 400, so only
// send it when set.
if key.TeamID != "" {
updateData["team_id"] = key.TeamID
}
if key.BudgetDuration != "" {
updateData["budget_duration"] = key.BudgetDuration
}

View file

@ -122,7 +122,7 @@ func TestUpdateKeyOmitsUnsetNewFields(t *testing.T) {
}
for _, k := range []string{
"budget_id", "enforced_params", "allowed_routes", "allowed_passthrough_routes",
"team_id", "budget_id", "enforced_params", "allowed_routes", "allowed_passthrough_routes",
"rpm_limit_type", "tpm_limit_type", "prompts", "organization_id",
} {
if _, present := captured[k]; present {