Skip to content

fix: prevent inconsistent result error on update with ignore_server_additions - #356

Open
jor2 wants to merge 1 commit into
Mastercard:mainfrom
jor2:fix/ignore-server-additions-update-inconsistency
Open

jor2 wants to merge 1 commit into
Mastercard:mainfrom
jor2:fix/ignore-server-additions-update-inconsistency

Conversation

@jor2

@jor2 jor2 commented Mar 27, 2026

Copy link
Copy Markdown

Fixes #355

Problem

When ignore_server_additions = true and an update is triggered by a change to update_data, update_path, update_method, path, or object_id (while data itself is unchanged), ModifyPlan was locking plan.APIData to the prior state value. After the update the server returns new api_data (e.g. a changed updated_at timestamp), which no longer matches the locked planned value, producing:

Error: Provider produced inconsistent result after apply
.api_data["metadata"]: updated_at value changed

Root cause

ModifyPlan checked only plan.Data.Equal(state.Data) to decide whether to lock api_data. This missed the case where data is unchanged but another attribute (e.g. update_data) triggers an update.

Fix

Mark api_data and api_response as unknown in the plan whenever any update-triggering attribute has changed, so Terraform does not enforce a specific post-apply value.

Test

Added TestAccRestApiObject_IgnoreServerAdditions_Update which:

  • Reproduces the exact failure (confirmed failing before the fix)
  • Includes a no-op step as a regression guard to verify api_data is still preserved when nothing changes

…dditions

When ignore_server_additions=true and an update is triggered by a change
to update_data, update_path, update_method, path, or object_id (while data
itself is unchanged), ModifyPlan was locking plan.APIData to the prior state
value. After the update the server returns new api_data (e.g. a changed
updated_at timestamp), which no longer matched the locked planned value,
causing "Provider produced inconsistent result after apply".

Fix by marking api_data and api_response as unknown in the plan whenever
any update-triggering attribute has changed, so Terraform does not enforce
a specific post-apply value.

Fixes Mastercard#355
@imprateeksh

Copy link
Copy Markdown

@DRuggeri - Could you please review this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error during update - Provider produced inconsistent result after apply

2 participants