fix: prevent inconsistent result error on update with ignore_all_server_changes - #359
Open
maxtwardowski wants to merge 1 commit into
Open
maxtwardowski wants to merge 1 commit into
maxtwardowski wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updatedoes not respectignore_all_server_changes, causing "Provider produced inconsistent result after apply" whenupdate_datachanges a field that the server echoes back.This is the same class of bug as #356 (which fixes
ignore_server_additions), but for theignore_all_server_changescode path.Problem
ModifyPlancorrectly preservesapi_dataandapi_responsefrom prior state whenignore_all_server_changes = true— telling Terraform these computed attributes won't change during apply.However,
Updateunconditionally callssetResourceModelData, which overwritesapi_dataandapi_responsewith values from the server response (either from the write response or the subsequent GET). When the update changes a field (e.g.name), the server returns the new value, creating a mismatch between what the plan promised and what the apply produced:This makes
ignore_all_server_changesincompatible withupdate_datafor any field the server echoes back.Reproduction
terraform apply— creates the resource successfully.var.nameand runterraform apply— plan correctly shows onlyupdate_datachanging.Fix
In
Update, whenignore_all_server_changesis true, preserveapi_dataandapi_responsefrom prior state instead of overwriting them from the server response. This mirrors the existing pattern inModifyPlan.Test plan
TestAccRestApiObject_IgnoreAllServerChanges_Update— creates a resource withignore_all_server_changes = trueandupdate_data, then changesupdate_datain a second step. Without the fix, step 2 fails with "Provider produced inconsistent result".TestAccRestApiObject_IgnoreAllServerChangesstill passes.