Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: don't use nil state for a computed attribute #878

Merged
merged 7 commits into from
Nov 28, 2024

Conversation

gersonsosa
Copy link
Contributor

@gersonsosa gersonsosa commented Nov 21, 2024

Description

If a computed attribute parent state is null, don't try to use the state to avoid inconsistency errors when the apply process finishes the state will still be used in the previous cases to preserve the same functionality.

https://elasticco.atlassian.net/browse/CP-9334

Related Issues

Motivation and Context

We found a bug while fixing the acceptance tests where multiple stateless components have this inconsistent behavior, in the eyes of terraform this is a bug.

The New State object returned from the provider must meet the following constraints:

  • Any attribute that had a known value in the Final Planned State must have an identical value in the new state. In particular, if the remote API returned a different serialization of the same value then the provider must preserve the form the user wrote in the configuration, and must not return the normalized form produced by the provider.

See the docs for more details https://github.com/hashicorp/terraform/blob/main/docs/resource-instance-change-lifecycle.md#applyresourcechange

How Has This Been Tested?

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improves code quality but has no user-facing effect)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Readiness Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

If a computed attribute parent state is null, don't try to use the state
  to avoid inconsistency errors when the apply process finishes
  the state will still be used in the previous cases to preserve the
  same functionality
@gersonsosa gersonsosa self-assigned this Nov 21, 2024
@gersonsosa gersonsosa marked this pull request as ready for review November 22, 2024 20:46
@gersonsosa gersonsosa requested a review from a team as a code owner November 22, 2024 20:46
@dimuon
Copy link
Contributor

dimuon commented Nov 28, 2024

@gersonsosa , the PR looks good besides one comment.

@gersonsosa gersonsosa requested a review from dimuon November 28, 2024 16:05
Copy link
Contributor

@dimuon dimuon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gersonsosa gersonsosa merged commit 3fa24e5 into elastic:master Nov 28, 2024
3 checks passed
@gersonsosa gersonsosa deleted the fix-plan-modifiers-apm branch November 28, 2024 18:24
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.

2 participants