-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Serialization of Infinity is null #158
Comments
Can i work on this, if its not assigned to anyone else? |
@rajatrawataku1 by all means. What I expect to happen is that the outputs of execution (contract state, response and emits) should all be validated, and a runtime error thrown if validation fails. Perhaps @jeromesimeon has some pointers? |
Thanks @rajatrawataku1 and @mttrbrts I would actually first look at this exact same issue in Concerto (https://github.com/accordproject/concerto). I wouldn't be surprised that serialising from a Concerto object with |
A bit of a review of concerto about this. The internals seem sound, using This could be done along the lines of: https://stackoverflow.com/questions/21896792/force-json-stringify-to-emit-nan-infinity-or-js-json-lib-that-does-so I would simply raise an error for
The benefit of that approach (and delaying the check to JSON.stringify) is that applications using the API would be able to handle results or inputs that include the full range of IEEE 754 values. |
@rajatrawataku1 would you still feel up to the task? This should include a review of everywhere we use |
Moving this back to open after 7 days. |
@mttrbrts Any thoughts on my alternative suggestion? Would you see any benefit in doing this at validation time rather than serialization time? |
Could I take a shot at this? I'm new to this project, and would appreciate some guidance! |
Sure @coderkalyan ! There is already quite a lot of details in this thread. Does it make sense to you, or which part is unclear? |
@coderkalyan yes, please feel free to pick this up. @jeromesimeon's approach is correct. IMO, the correct place to fix this is in the ResourceValidator in Concerto
If we raise validation errors for |
No activity on this for a while, I'm releasing the ownership for now. |
…rror accordproject#158 Signed-off-by: Jerome Simeon <[email protected]>
A fix for this issue, by changing |
…rror accordproject#158 Signed-off-by: Jerome Simeon <[email protected]>
That fix has been refactored to be done in the |
…rror #158 Signed-off-by: Jerome Simeon <[email protected]>
Fixed based on proposal in #161 in the |
…rror accordproject#158 Signed-off-by: Jerome Simeon <[email protected]>
…rror #158 Signed-off-by: Jerome Simeon <[email protected]>
…rror accordproject#158 Signed-off-by: Jerome Simeon <[email protected]>
…rror #158 Signed-off-by: Jerome Simeon <[email protected]>
…rror #158 Signed-off-by: Jerome Simeon <[email protected]>
…rror #158 Signed-off-by: Jerome Simeon <[email protected]>
Describe the bug
When an expression sets a value in the state to
Infinity
, this gets serialized (throughJSON.stringify
?) tonull
. This has the effect of invalidating the state instance and rendering the contract unable to accept new requests.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description
To Reproduce
Steps to reproduce the behavior:
infinity.ergo
model.cto
state.json
contract.json
request.json
When you run ...
Notice the value of
value
in the state response.If you then update the value of
state.json
with the new state, it will fail to pass validation.Expected behavior
The engine should throw a runtime error, perhaps similar to an
enforce
response, to alert the client to the overflow and protect corruption of the state.The text was updated successfully, but these errors were encountered: