Skip to content

Conversation

@zliang-akamai
Copy link
Member

@zliang-akamai zliang-akamai commented Aug 8, 2025

📝 Description

Previously the value of a JSON parameter passed in by the user had to go through _traverse_request_body function 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:

linode-cli linodes create \
  --image 'linode/ubuntu24.04' \
  --interface_generation linode \
  --interfaces '[{"firewall_id":123456,"public":{}}]' \
  --private_ip false \
  --region us-mia \
  --type g6-nanode-1 \
  --label test-cli-create-linode-public \
  --root_pass 'this-is-an-unsafe-password' \
  --disk_encryption enabled --debug

The JSON value parameter interfaces with 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 key a would 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 ExplicitEmptyDictValue can be safely removed because the empty dict will also be wrapped in ExplicitJsonValue.

✔️ How to Test

make install && linode-cli linodes create \
  --image 'linode/ubuntu24.04' \
  --interface_generation linode \
  --interfaces '[{"firewall_id":1629606,"public":{}}]' \
  --private_ip false \
  --region us-ord \
  --type g6-nanode-1 \
  --label test-cli-create-linode-public \
  --root_pass 'this-is-an-unsafe-password' \
  --disk_encryption enabled --debug

@zliang-akamai zliang-akamai added the bugfix for any bug fixes in the changelog. label Aug 8, 2025
@zliang-akamai zliang-akamai requested a review from a team as a code owner August 8, 2025 05:45
@zliang-akamai zliang-akamai added the breaking-change for breaking changes in the changelog. label Aug 8, 2025
@zliang-akamai zliang-akamai requested review from ezilber-akamai and jriddle-linode and removed request for a team August 8, 2025 05:45
@zliang-akamai zliang-akamai changed the title Pass JSON value parameter as is to the API call Pass input JSON value parameter as-is to the API call Aug 8, 2025
Copy link
Contributor

@lgarber-akamai lgarber-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! As privately discussed, this is technically a breaking change but it likely doesn't have a large impact and better aligns with the expectations our documentation sets for users.

Copy link
Contributor

@ezilber-akamai ezilber-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@zliang-akamai zliang-akamai merged commit 254a70f into linode:dev Aug 19, 2025
14 checks passed
@zliang-akamai zliang-akamai deleted the zhiwei/pass-json-value-as-is branch August 19, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change for breaking changes in the changelog. bugfix for any bug fixes in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants