Skip to content
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

tfprotov5+tfprotov6: Add DynamicValue Null Checking Without Type Information #305

Closed
bflad opened this issue Jun 27, 2023 · 1 comment · Fixed by #306
Closed

tfprotov5+tfprotov6: Add DynamicValue Null Checking Without Type Information #305

bflad opened this issue Jun 27, 2023 · 1 comment · Fixed by #306
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bflad
Copy link
Contributor

bflad commented Jun 27, 2023

terraform-plugin-go version

v0.16.0

Use cases

terraform-plugin-mux, tfprotov5.ProviderServer, and tfprotov6.ProviderServer implementations generally need to check whether a DynamicValue is null. For example, this type of check can be used in PlanResourceChange RPCs to verify whether the intended resource operation is creation or deletion. Currently, DynamicValue only supports an Unmarshal() method, which must be given the expected type information (e.g. from a schema), which may not always be available immediately in implementations.

Attempted solutions

Caching schema information, calling (DynamicValue).Unmarshal(), then checking (tftypes.Value).IsNull().

Proposal

Checking whether a DynamicValue is null can be performed by peeking into the underlying JSON and MessagePack data without fully decoding it. JSON data should have a null value (nil json.Token) and MessagePack data should have a msgpcode.Nil code.

In both tfprotov5 and tfprotov6 packages, add a new IsNull() method to the DynamicValue type.

References

@bflad bflad added the enhancement New feature or request label Jun 27, 2023
@bflad bflad added this to the v0.17.0 milestone Jun 27, 2023
@bflad bflad self-assigned this Jun 27, 2023
bflad added a commit that referenced this issue Jun 27, 2023
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant