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

Fix conditionals erroring with an unknown condition and marked branch. #630

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

cube2222
Copy link
Contributor

@cube2222 cube2222 commented Oct 5, 2023

Fixes #629 and transitively also opentofu/opentofu#655 and hashicorp/terraform#33977.

Solution inspired by other implementations in this very file, as well as primitive functions in the go-cty repository itself.

Signed-off-by: Jakub Martin <kubam@spacelift.io>
@apparentlymart
Copy link
Contributor

apparentlymart commented Oct 6, 2023

Thanks for digging into this, @cube2222!

This fix seems right to me. As you've seen, the Value.Range API can't safely accept marked values because not all of the methods of ValueRange can propagate marks to their results, and so applications/libraries that use marks must always unmark their values first.


FWIW, I've just released a new version v1.14.1 of my cty library, which is what's providing this "refinements" concept to HCL and Terraform, so that it'll produce a clearer panic message in response to caller bugs like this one. The new message will be "Value.Range on marked value; must be unmarked first", and so in any other situations where that appears I expect the solution will be a change similar to the one made in this PR.

With my cty maintainer hat on, (instead of my HashiCorp employee hat), I'd recommend callers of HCL upgrade to the latest cty along with upgrading HCL to get better feedback on other instances of this genre of bug, if any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conditionals with unknown conditions and marked branches are erroring.
2 participants