Pass input JSON value parameter as-is to the API call #807
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 Description
Previously the value of a JSON parameter passed in by the user had to go through
_traverse_request_bodyfunction to have null or empty list/dict values remove. We did have a way to allow explicit empty dict/list but that won't work if the empty dict/list is nested in the JSON object.Here is an example:
The JSON value parameter
interfaceswith user input JSON string'[{"firewall_id":123456,"public":{}}]'would be translated into an invalid API call request body attribute, which had{}removed:{ "interfaces": [{"firewall_id": 2431805}] }(irrelevant attributes in the body are ignored)
This change will let the CLI to pass whatever user input as-is into the request body to resolve this issue.
This is a potential breaking change because if user passed in some JSON like
{"a": {}, b: {"key": "value"}}and expected keyawould be dropped, this change will break their code. But I believe this change is necessary to make CLI behaviors correct and there isn't another easy way to fix the bug.I think
ExplicitEmptyDictValuecan be safely removed because the empty dict will also be wrapped inExplicitJsonValue.✔️ How to Test