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

don't marshal integer values as msgpack floats #396

Merged
merged 4 commits into from
Apr 18, 2024

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Apr 17, 2024

Round-tripping a large integer through a float64, even if the binary representation is exact, causes us to end up with a rounded string representation after decoding, because the decoded number has 52-bit precision instead of the 512 we use when dealing with string representations of large integers.

The test fixture was changed slightly to compare only the final value string representations, which more closely corresponds to the configuration and state values. The comparison of the Value directly will contain differences in the underlying math/big value.

This mirrors the upstream change in go-cty here, which will be incorporated into the next version of Terraform, ensuring that the round-trip encoding of values is the same in both directions.

Fixes #391

Round-tripping a large integer through a float64, even if the binary
representation is exact, causes us to end up with a rounded string
representation after decoding, because the decoded number has 52-bit
precision instead of the 512 we use when dealing with string
representations of large integers.
@jbardin jbardin requested a review from a team as a code owner April 17, 2024 20:20
@austinvalle austinvalle added this to the v0.23.0 milestone Apr 18, 2024
Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'll push a changelog to your branch before merging 👍🏻

Note: You'll see me open another PR temporarily with these exact changes because our workflows are currently busted when a PR comes from a fork and don't run our CI tests 🙃
https://github.com/hashicorp/terraform-plugin-go/actions/runs/8740923855?pr=396

@bflad bflad added the bug Something isn't working label Apr 18, 2024
@austinvalle austinvalle modified the milestones: v0.23.0, v0.22.2 Apr 18, 2024
@austinvalle
Copy link
Member

All workflows are green over in https://github.com/hashicorp/terraform-plugin-go/actions/runs/8741201175?pr=397 🟢

Thanks for the fix @jbardin!

@austinvalle austinvalle merged commit 865883d into hashicorp:main Apr 18, 2024
6 checks passed
austinvalle added a commit that referenced this pull request Apr 19, 2024
* don't marshal integer values as msgpack floats

Round-tripping a large integer through a float64, even if the binary
representation is exact, causes us to end up with a rounded string
representation after decoding, because the decoded number has 52-bit
precision instead of the 512 we use when dealing with string
representations of large integers.

* update CHANGELOG.md

* update to changie log

---------

Co-authored-by: Austin Valle <[email protected]>
austinvalle added a commit that referenced this pull request May 6, 2024
* generate protocol bindings

* add protocol bindings to external interface

* build(deps): Bump google.golang.org/grpc from 1.63.0 to 1.63.2 (#394)

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.63.0 to 1.63.2.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.63.0...v1.63.2)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* workflows: Remove wildcard suffix from Terraform workflow call (#395)

* don't marshal integer values as msgpack floats (#396)

* don't marshal integer values as msgpack floats

Round-tripping a large integer through a float64, even if the binary
representation is exact, causes us to end up with a rounded string
representation after decoding, because the decoded number has 52-bit
precision instead of the 512 we use when dealing with string
representations of large integers.

* update CHANGELOG.md

* update to changie log

---------

Co-authored-by: Austin Valle <[email protected]>

* Update changelog

* breaking: update protocol bindings for new client capabilities struct + add configure provider bindings

* add Go pkg docs

* add copywrite headers

* add changelog

* split client capabilities per RPC

* added logging for req/resp deferred actions

* add test for ensuring global variable is updated

* add diagnostic for invalid deferred

* move helper diag into function

* add a separate log for nil client capabilities

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: James Bardin <[email protected]>
Co-authored-by: hc-github-team-tf-provider-devex <[email protected]>
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coordinate switch in message pack encoding for large integers with Terraform core
3 participants