-
Notifications
You must be signed in to change notification settings - Fork 99
identity: Update change validation to ensure empty identities (all null attributes) are not validated #1229
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
Merged
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
Member
Author
|
Original test failures without the fix applied in 02a37e3: --- FAIL: TestServerReadResource (0.00s)
--- FAIL: TestServerReadResource/response-identity-valid-update-empty-currentidentity (0.00s)
server_readresource_test.go:1001: unexpected difference: &fwserver.ReadResourceResponse{
Deferred: nil,
- Diagnostics: diag.Diagnostics{
- diag.ErrorDiagnostic{
- detail: "During the read operation, the Terraform Provider unexpectedly r"...,
- summary: "Unexpected Identity Change",
- },
- },
+ Diagnostics: nil,
NewState: &{Raw: s`tftypes.Object["test_computed":tftypes.String, "test_required":t`..., Schema: schema.Schema{Attributes: {"test_computed": schema.StringAttribute{Computed: true}, "test_required": schema.StringAttribute{Required: true}}}},
NewIdentity: &{Raw: s`tftypes.Object["test_attr_a":tftypes.String, "test_attr_b":tftyp`..., Schema: identityschema.Schema{Attributes: {"test_attr_a": identityschema.StringAttribute{RequiredForImport: true}, "test_attr_b": identityschema.Int64Attribute{OptionalForImport: true}}}},
Private: &{Provider: &{data: {}}},
}
--- FAIL: TestServerPlanResourceChange (0.01s)
--- FAIL: TestServerPlanResourceChange/update-resourcewithmodifyplan-empty-prioridentity-plannedidentity-changed (0.00s)
server_planresourcechange_test.go:7124: unexpected difference: &fwserver.PlanResourceChangeResponse{
Deferred: nil,
- Diagnostics: diag.Diagnostics{
- diag.ErrorDiagnostic{
- detail: "During the planning operation, the Terraform Provider unexpected"...,
- summary: "Unexpected Identity Change",
- },
- },
+ Diagnostics: nil,
PlannedPrivate: &{Provider: &{data: {}}},
PlannedState: &{Raw: s`tftypes.Object["test_computed":tftypes.String, "test_required":t`..., Schema: schema.Schema{Attributes: {"test_computed": schema.StringAttribute{Computed: true}, "test_required": schema.StringAttribute{Required: true}}}},
... // 2 identical fields
}
--- FAIL: TestServerApplyResourceChange (0.00s)
--- FAIL: TestServerApplyResourceChange/update-response-newidentity-empty-plannedidentity (0.00s)
server_applyresourcechange_test.go:2228: unexpected difference: &fwserver.ApplyResourceChangeResponse{
- Diagnostics: diag.Diagnostics{
- diag.ErrorDiagnostic{
- detail: "During the update operation, the Terraform Provider unexpectedly"...,
- summary: "Unexpected Identity Change",
- },
- },
+ Diagnostics: nil,
NewState: &{Raw: s`tftypes.Object["test_computed":tftypes.String, "test_required":t`..., Schema: schema.Schema{Attributes: {"test_computed": schema.StringAttribute{Computed: true}, "test_required": schema.StringAttribute{Required: true}}}},
NewIdentity: &{Raw: s`tftypes.Object["test_attr_a":tftypes.String, "test_attr_b":tftyp`..., Schema: identityschema.Schema{Attributes: {"test_attr_a": identityschema.StringAttribute{RequiredForImport: true}, "test_attr_b": identityschema.Int64Attribute{OptionalForImport: true}}}},
Private: &{Provider: &{data: {}}},
}
FAIL |
rainkwan
approved these changes
Sep 22, 2025
|
|
||
| // If we're refreshing the resource state (excluding a recently imported resource), validate that the new identity isn't changing | ||
| if !req.ResourceBehavior.MutableIdentity && !readFollowingImport && !req.CurrentIdentity.Raw.IsNull() && !req.CurrentIdentity.Raw.Equal(resp.NewIdentity.Raw) { | ||
| if !req.ResourceBehavior.MutableIdentity && !readFollowingImport && !req.CurrentIdentity.Raw.IsFullyNull() && !req.CurrentIdentity.Raw.Equal(resp.NewIdentity.Raw) { |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FullyNull is an interesting way to say it
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Related Issue
Description
There are some scenarios where an identity may be stored with all null values (a scenario that #1193 will eventually prevent from occurring), which should not be validated, since an identity with all null values is invalid.
The only real possibility of this happening ATM is with:
terraform-plugin-gowhich was storing all null attributes (there is no validation in the lower-level SDK)Rollback Plan
Changes to Security Controls
No