-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Planned value does not match config value for number #34866
Comments
Thanks @bendbennett! This is quite peculiar, because while the plan appears to have stored the truncated value, at least within Terraform alone the final state still ends up with the correct If your example (which I haven't tried yet) ends up with the incorrect value in state, then there is a separate bug to track down somewhere in the protocol/framework. |
This is also potentially related to #34686, which I thought had been fixed. There might have been another rendering path somewhere that has been missed. |
Just as little addition here:
The correct value is written within the |
The problematic number raised here is
And the same pattern seems to continue, with other numbers around those numbers being unaffected and only the exact whole numbers being truncated. I don't have an explanation for this, and I don't think this is in the rendering code of the human-readable plan as this is being printed by the JSON output as well. Very strange. |
Also, no number satisfying |
These seem like the "breakpoints" where the floating point exponent would increase, making the mantissa the same (1) for all of these examples, right? So it seems like what they have in common is that the exponent is >= 63 and the exponent is 1. I don't know what to conclude from that yet, but it is at least an interesting pattern! |
There's still something in |
One way we've seen symptoms like this before was accidentally creating a |
I've debugged enough to at least describe the circumstances that cause the bug: If the given number is a whole number that would fit in an int64 then If the number is too big for an int64 then Therefore it seems that the problem is in the round-tripping of some values when they get encoded as |
It does indeed seem to be a repeat of the " Explicitly setting the precision to 512 (which is the convention elsewhere in I'm going to fix this upstream by explicitly setting the precision to 512 before populating the |
Actually, I've changed my mind: unilaterally deciding to expand the precision of all numbers when converting to Instead of pretending incoming values are higher precision than they are, we instead expand the precision "just in time" during the operations that would benefit from it, so that we're doing calculations with higher precision when needed, but avoid implying in string representations that there's more precision available than was present in the source value. I think the most narrow fix here is to avoid using the |
I've fixed this upstream in cty v1.14.4. The specific commit is zclconf/go-cty@f41ae52 . However, it's important to note that I fixed this by changing the MessagePack encoder to use a different encoding for large integers. I'm not sure which was causing the problem here -- perhaps it's both, since we round-trip through MessagePack in both directions after all -- but either way I would suggest making a similar change to I'm not going to propose any upgrade change in Terraform yet, because I expect we'll probably want to coordinate the |
Thank you all for the comprehensive investigation and feedback everyone. Much appreciated. |
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. |
Terraform Version
Terraform Configuration Files
Debug Output
https://gist.github.com/bendbennett/694e16874249f8aaa1a9ab14da84129f
Expected Behavior
Expecting the plan displayed by the CLI to look as follows:
Actual Behavior
Plan displayed by the CLI looks as follows:
The value stored in state matches that from the plan, but differs from that supplied in the configuration:
Steps to Reproduce
terraform apply
Additional Context
This appears to be specific to the value of the integer supplied in the configuration (i.e., 9223372036854775808).
The structure of the provider is as follows:
The
v1.8.0-beta1
version of Terraform appears to be usinggithub.com/zclconf/go-cty v1.14.3
which contains the fix for a previously reported, somewhat similar issue - #34589References
The text was updated successfully, but these errors were encountered: