-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add correct processing for non-existent json-keys #5511
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this lgtm—just unsure if this conforms to the earlier spec we had — @mds1 would love an eye on this!
Sanity checking my understanding: previously calling Also @klkvr you might know this, but there's a |
Yes, that's right
I know about it, but for me it's easier when code just reverts, because inserting sanity-checks everywhere makes code less readable IMO |
This is technically a breaking change @mds1 — should we merge or hold off? |
I'd say merge (and include in the changelog) because the existing behavior feels like a footgun. We don't want to return data for a field that doesn't exist, since there really is no data. Potentially related to #3754 (comment) where 32 used to be erroneously returned |
@Evalir |
whoops my bad, mixed another unrelated change here |
626c420
to
0574666
Compare
* Add correct processing for non-existent keys * Fix clippy error * chore: include changes in changelog --------- Co-authored-by: Enrique Ortiz <[email protected]>
Motivation
Right now following code will return
uint256(32)
:abi.decode(vm.parseJson('{"a": 1}', '.b'), (uint256))
while expected behavior would be for it to revert becausevm.parseJson('{"a": 1}', '.b')
should result inbytes("")
But, in fact, it results in
0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000 == abi.encode(bytes(""))
Solution
Add processing of edge case when there are no json tokens corresponding to given path