-
Notifications
You must be signed in to change notification settings - Fork 91
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
BUG: asset or metadata fields need to be stringified (no float) #88
Comments
Mhh, I wonder if the stringification of an asset's float should be the user's responsibility.
/cc @vrde @r-marques |
What's the status on this one? I think it's not the responsibility of the js-driver. I choose for option 3? |
It's not the responsibility of the driver, except for maybe its documentation. @ttmc Where do you think this information should be documented? |
Is the general rule: RULE: In the JSON contents of "asset" and "metadata", each value must be either a string or another JSON object (not an integer, float or other type). If so, then this is something that can be checked by BigchainDB Server as one of the transaction validity conditions. Drivers and other tools can do whatever they like, but if they want to be useful, then they shouldn't build transactions with non-strings in the leaf values of "asset" or "metadata". If we implement this check in BigchainDB Server, and we probably should, then it should be documented in the BigchainDB Server docs about "asset" and "metadata". I will create an issue for this on the BigchainDB Server repo. |
If so, then please make sure that the error returned is appropriately labeled. This wasnt the case before |
From https://jsfiddle.net/mdq41f16/ I still get the same error {
"message": "Invalid transaction (InvalidHash): The transaction's id '19103d69d9983672782e7be437ec28e2e43db37be296bf029d8b78be9b693155' isn't equal to the hash of its body, i.e. it's not valid.",
"status": 400
} Are we planning to change this error? |
The current thinking about how to handle floats in It will mean changing the transaction model, and there are many proposed changes to the transaction model. We probably won't be making any of those transaction model changes, except for the ones required by Tendermint integration, until after Tendermint integration. |
There are some subtle issues around floats, for instance I'm working on the java-bigchaindb-driver and the scale of BigDecimal isn't being respected. For instance sending a value 16.00 is being truncated to 16.0 as an example, this of course leads to an incorrect hash being generated (also hampered by the lack of debug logging in the server) |
@agwego That's a great example of why floats are problematic. Big integers, Infinity and NaN have similar issues. That's why part of the proposal in bigchaindb/bigchaindb#1900 is to disallow JSON numbers completely in Until we change the transaction model (on the server side), you can enforce non-usage of JSON numbers in your application code or driver code. |
Using float values might lead to
InvalidHash
errors on the serverie using the following metadata:
The text was updated successfully, but these errors were encountered: