Closed romanhabibov closed 3 years ago
Hi! Thank you for the patch! According to https://github.com/tarantool/tarantool/wiki/Code-review-procedure#commit-message the commit title might look like: "parsing:..." Add a commit message describing how it reproduced (
curl ...
) and what did you do to fix the bug.
See reproducer in the new test file.
In addition, I could not run the tests, can you describe how to run them.
See my new pull request. Start NginX and Tarantool instances with https://github.com/tarantool/nginx_upstream_module/tree/test#test-run-and-notes-for-contributors, and then you can use this pattern for testing:
curl -s -d '{"id":0,"method":"skipping_test","params":[]}' http://127.0.0.1:8081/tnt | jq
.
Hi! Thank you for the patch. Add @ChangeLog.
Done.
AFAIU "skipping method" don't exist before the patch. So in context "Add better skipping method for garbage fields when parsing json." better than nothing? Add more detailed description with explanation what is not "garbage".
Done.
LGTM except #138 (comment) .
Done.
We don't need to introduce the second primitive for tracking the nesting level: the code already have so called stack
. What is incorrect now: it tracks only those arrays and maps that are inside "params" value. The code also have the implementation of skipping unknown fields: everything that is not inside "params" (+few other cases) is skipped. The only thing we should fix is to move nesting tracking outside stage == PARAMS
checks.
Please, consider the patch below. It seems, it passes all tests, however I'm not sure it is quite accurate.
The same patch as a file (for applying convenience): gh-132-skip-unknown-fields.patch.zip
Aside of stack calculations fix I simplified the logic around TYPE_MAP | PARAMS
and TYPE_ARRAY | PARAMS
. We don't need to store the PARAMS
flag when an array or a map is started. This flag depends on the nesting level and whether we're parsing "params" value. This information is available when we meet the array / map end, so we can use it directly.
We don't need to introduce the second primitive for tracking the nesting level: the code already have so called
stack
. What is incorrect now: it tracks only those arrays and maps that are inside "params" value. The code also have the implementation of skipping unknown fields: everything that is not inside "params" (+few other cases) is skipped. The only thing we should fix is to move nesting tracking outsidestage == PARAMS
checks.Please, consider the patch below. It seems, it passes all tests, however I'm not sure it is quite accurate.
Patch for reading The same patch as a file (for applying convenience): gh-132-skip-unknown-fields.patch.zip
Aside of stack calculations fix I simplified the logic around
TYPE_MAP | PARAMS
andTYPE_ARRAY | PARAMS
. We don't need to store thePARAMS
flag when an array or a map is started. This flag depends on the nesting level and whether we're parsing "params" value. This information is available when we meet the array / map end, so we can use it directly.
I checked your patch and found no problems. I'm OK.
I don't see downsides in the code. You too. So, it looks as the way to go.
Please, fix remaining questions regarding the test.
Then we'll able to push this PR (but after #141).
@ChangeLog