From 9ed1ca3399b9c95ada193c3d96a0ab99aba9f60c Mon Sep 17 00:00:00 2001 From: Erik Bogado Date: Mon, 7 Sep 2026 03:41:11 -0300 Subject: [PATCH] fix(terraform): omit empty key team updates --- terraform/provider/litellm/client.go | 4 +++- terraform/provider/litellm/resource_key_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/terraform/provider/litellm/client.go b/terraform/provider/litellm/client.go index 0f825d85d31..d6625f6c710 100644 --- a/terraform/provider/litellm/client.go +++ b/terraform/provider/litellm/client.go @@ -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 } diff --git a/terraform/provider/litellm/resource_key_test.go b/terraform/provider/litellm/resource_key_test.go index 91f0061a9ef..5edba1589cd 100644 --- a/terraform/provider/litellm/resource_key_test.go +++ b/terraform/provider/litellm/resource_key_test.go @@ -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 {