Skip to content

Empty list attributes cause perpetual diffs/replacements due to null vs [] mismatch#2997

Open
cgeiaws wants to merge 3 commits intohashicorp:mainfrom
cgeiaws:fix/empty-list-state-handling
Open

Empty list attributes cause perpetual diffs/replacements due to null vs [] mismatch#2997
cgeiaws wants to merge 3 commits intohashicorp:mainfrom
cgeiaws:fix/empty-list-state-handling

Conversation

@cgeiaws
Copy link

@cgeiaws cgeiaws commented Feb 6, 2026

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request
  • The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the CloudFormation Open Coverage Roadmap.

Closes #2993

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the library.

Changes to Security Controls

No changes to security controls.

Description

This PR fixes perpetual diffs/replacements caused by empty list attributes being converted to null in Terraform state.

Problem

When a user configures an empty list (e.g., creator_member_abilities = []), the AWS API either:

  1. Returns an empty array [], or
  2. Omits the field entirely

The provider's translate.go was converting both cases to null in Terraform state. This caused a mismatch between the user's config ([]) and state (null), triggering RequiresReplaceIfConfigured() plan modifiers on every plan.

Solution

Modified internal/generic/translate.go to preserve empty lists/sets:

  1. When AWS returns an empty array [], preserve it as an empty list instead of nil
  2. When AWS omits a list/set field entirely, set it to empty [] instead of null

Testing

  • Updated two unit tests in translate_test.go to expect empty lists instead of nil
  • All existing unit tests pass

Affected Resources

This fix benefits any resource with optional list/set attributes, including:

  • awscc_cleanrooms_collaboration (creator_member_abilities)
  • awscc_cleanrooms_configured_table_association (configured_table_association_analysis_rules)
  • Any other resource where users configure empty lists

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty list attributes cause perpetual diffs/replacements due to null vs [] mismatch

1 participant