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

tftypes: Disallow msgpack unmarshalling to call NewValue(DynamicPseudoType, nil) #96

Closed
bflad opened this issue Aug 9, 2021 · 2 comments · Fixed by #99
Closed

tftypes: Disallow msgpack unmarshalling to call NewValue(DynamicPseudoType, nil) #96

bflad opened this issue Aug 9, 2021 · 2 comments · Fixed by #99
Assignees
Labels
bug Something isn't working
Milestone

Comments

@bflad
Copy link
Contributor

bflad commented Aug 9, 2021

terraform-plugin-go version

main branch after #94 is reviewed/merged, but should be handled before next release

Relevant Code

switch {
case length == -1:
return NewValue(DynamicPseudoType, nil), nil
case length != 2:
return Value{}, path.NewErrorf("expected %d elements in DynamicPseudoType array, got %d", 2, length)
}

Expected Behavior

Code should return error instead of calling NewValue() in manner that will panic.

Actual Behavior

If condition is hit after #94 is merged, code will panic.

Steps to Reproduce

Needs unit test added.

References

@bflad bflad added the bug Something isn't working label Aug 9, 2021
@paddycarver
Copy link
Contributor

We should, at the very least, be using newValue instead of NewValue, so we can handle the error instead of panicking.

@bflad bflad self-assigned this Aug 10, 2021
@bflad bflad added this to the v0.4.0 milestone Aug 10, 2021
@bflad bflad changed the title tftypes: Disallow msgpack unmarshalling to call NewValue(DynamicPseudoType, nil) or other known values tftypes: Disallow msgpack unmarshalling to call NewValue(DynamicPseudoType, nil) Aug 10, 2021
bflad added a commit that referenced this issue Aug 10, 2021
bflad added a commit that referenced this issue Aug 10, 2021
bflad added a commit that referenced this issue Aug 10, 2021
@bflad bflad closed this as completed in #99 Aug 16, 2021
bflad added a commit that referenced this issue Aug 16, 2021
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 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
2 participants