Skip to content

Conversation

@rainkwan
Copy link
Contributor

@rainkwan rainkwan commented Apr 2, 2025

Most of the “invalid” identity attribute types are simply not possible to create with Framework (without abusing custom types, which we can safely ignore imo) because we have a dedicated “identityschema” package: https://github.com/hashicorp/terraform-plugin-framework/tree/main/resource/identityschema

The lone validation we need to apply at runtime is checking the element type of the “identityschema.ListAttribute” since there is no restriction on what kind of “attr.Type” is provided. The only allowed element types are:

types.Bool

types.Int64, types.Int32, types.Float64, types.Float32, types.Number

types.String

The validation was done in the ValidateImplementation function which runs during GetResourceIdentitySchemas.

Added AttributeInvalidElementTypeDiag to give the error message and IsAllowedPrimitiveType to check to see if the element is an allowed type.

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.

Looking good 👍🏻 , I have some suggestions for the case switch + diagnostic messaging, but all the functionality looks correct!

@rainkwan rainkwan force-pushed the rk/resource-identity-validation branch from 7062e88 to 66ae7b6 Compare April 15, 2025 15:06
@rainkwan rainkwan force-pushed the rk/resource-identity-validation branch from 66ae7b6 to 49ed817 Compare April 16, 2025 15:29
@rainkwan rainkwan requested a review from austinvalle April 16, 2025 15:48
@austinvalle austinvalle added this to the v1.15.0 milestone Apr 17, 2025
austinvalle
austinvalle previously approved these changes Apr 17, 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.

Just had one small adjustment to the error message, great work on this! 🙌🏻

@rainkwan rainkwan merged commit 83df4b6 into main Apr 18, 2025
35 checks passed
@rainkwan rainkwan deleted the rk/resource-identity-validation branch April 18, 2025 20:07
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 19, 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.

3 participants