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

Update zome API structs to use strings for passing numerical values, avoiding potential value truncation #382

Open
pospi opened this issue Jan 31, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@pospi
Copy link
Member

pospi commented Jan 31, 2023

In 81ad8e6 a temporary measure was added for compatibility with the latest VF-GraphQL spec without requiring extensive updates to the zome APIs. To prevent any possible numerical truncation, the new Decimal type should be de/serialized as a string rather than a JavaScript number.

This will require a new externally-facing variant of the QuantityValue struct where has_numerical_value is a String. Custom serialization logic will need to be added to convert to/from the external string-based representation to an internal Rust format that is able to handle accurate arbitrary-precision decimal math. There are probably crates that integrate with Serde to do this automatically, but some investigation needs to be made.

Filing this as a bug since until these changes are made, very large values (in excess of 2^1024-1) will be truncated before sending. Since such use-cases are likely to be very rare, we can consider this a low priority issue.

@pospi pospi added the bug Something isn't working label Jan 31, 2023
@pospi pospi changed the title Update zome API structs to use strings for passing numerical values Update zome API structs to use strings for passing numerical values, avoiding potential value truncation Jan 31, 2023
@pospi
Copy link
Member Author

pospi commented Feb 5, 2023

(Probably best to add that I'm unclear on the details re maximum expressible values in JS; could equally be 2^53 - 1 or some other value depending on floating point storage overhead and script engine.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant