Skip to content

Conversation

bbasata
Copy link
Contributor

@bbasata bbasata commented Jul 18, 2025

Related Issue

For hashicorp/terraform-plugin-framework#1193, to fix hashicorp/terraform-plugin-framework#1184.

Description

This pull request adds a method to tftypes.Value that returns true for an object that has all null attributes. In this way, IsNull/IsFullyNull mirror the existing IsKnown/IsFullyKnown.

For example, the equivalent tftypes.Value of this value is "fully null":

"identity": { // <---------------- all identity attributes are null
    "account_id": null,
    "bucket": null,
    "region": null
}

This introduces no behavior changes to terraform-plugin-go. It provides a type system utility for SDKs to consume. For example, terraform-plugin-framework can use tftypes.Value.IsFullyNull() to reject "fully null" resource identity values from RPC responses.

cc: @austinvalle

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

No.

@bbasata bbasata changed the title tftypes: add tftypes.IsFullyNull() tftypes: add tftypes.Value.IsFullyNull() Jul 24, 2025
@bbasata bbasata marked this pull request as ready for review July 24, 2025 13:49
@bbasata bbasata requested a review from a team as a code owner July 24, 2025 13:49
bbasata added a commit to hashicorp/terraform-plugin-framework that referenced this pull request Jul 28, 2025
bbasata added a commit to hashicorp/terraform-plugin-framework that referenced this pull request Jul 28, 2025
austinvalle
austinvalle previously approved these changes Jul 29, 2025
Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

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

Code itself looks good, I did have one question. Can we also add a changelog for this?

@bbasata
Copy link
Contributor Author

bbasata commented Jul 29, 2025

cc: @dbanck

In Plugin SDK and Framework, we will return an error diagnostic when a null or "empty" resource identity would be returned for a resource that has an identity schema.

As defined here, "empty" (or IsFullyNull) means that the value is a null primitive or the value is an aggregate that consists of only empty elements and attributes. So it's "deeply empty" 😢. Any aggregate of lists of null/empty values, objects of null/empty values, etc.

How well does this agree with Terraform?

@bbasata bbasata merged commit dfefeb8 into main Jul 30, 2025
102 checks passed
@bbasata bbasata deleted the practically-null branch July 30, 2025 16:19
@bbasata bbasata added this to the v0.29.0 milestone Jul 30, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Framework allows resource identities to be set to null, eventually triggering mutable identity error
3 participants