From 09def488cdbda02e485985d0ec48bcf547b6f578 Mon Sep 17 00:00:00 2001 From: "Eric K. Sender" Date: Thu, 10 Sep 2026 08:02:01 -0700 Subject: [PATCH] fix(terraform): keep prior state when /key/update is rejected A rejected update must not persist its values into state. Without partial mode the SDK writes the proposed config into state even when Update returns an error, so a 400 (e.g. invalid budget_duration) leaked the rejected values. Enable partial mode on the UpdateKey error path, mirroring the plannedKeyMetadata error branch above it. Fixes the 'gofmt, vet, build, test' failure in the Terraform Provider workflow (TestResourceKeyUpdateFailureKeepsPriorState). --- terraform/provider/litellm/resource_key.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/terraform/provider/litellm/resource_key.go b/terraform/provider/litellm/resource_key.go index ffdc448f5fe..641285d980e 100644 --- a/terraform/provider/litellm/resource_key.go +++ b/terraform/provider/litellm/resource_key.go @@ -327,6 +327,11 @@ func resourceKeyUpdate(ctx context.Context, d *schema.ResourceData, m interface{ key.Metadata = metadata if _, err := c.UpdateKey(key); err != nil { + // The proxy rejected the whole update, so nothing was applied + // server-side. Keep prior state instead of persisting the + // rejected values: without partial mode the SDK writes the + // proposed config into state even when Update returns an error. + d.Partial(true) return diag.FromErr(fmt.Errorf("error updating key: %s", err)) }