terraform-plugin-sdk
terraform-plugin-sdk copied to clipboard
Validate result from `UpgradeResourceIdentity` matches current schema
Currently there are no safe-guards when resource identity upgrade functions are called. This mirrors the existing design for state upgrade functions that have the exact same problem.
This means that an erroneous implementation in the provider can lead to parts of the identity being accidentally set as null values if no new value is set (i.e. if the new identity version has new fields). This happens because Terraform doesn't validate the identity against its schema anymore.
We could add some validation to the upgradeJSONIdentity function
https://github.com/hashicorp/terraform-plugin-sdk/blob/c778fc76baf65fd3790fb13ed5c5497bf1fb4e20/helper/schema/grpc_provider.go#L2331-L2347 to show an error instead. This error would then tell the user that this is a bug in the provider and should be reported to its maintainer.