mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-15 09:12:18 +00:00
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).
This commit is contained in:
parent
5b394923b0
commit
09def488cd
1 changed files with 5 additions and 0 deletions
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue