Description
When passing complex JSON parameters (--nsg-ids, --metadata, --defined-tags, --shape-config, etc.) with invalid JSON, the error message is opaque: it uses the internal Python parameter name (lisp_case) instead of the CLI flag the user typed, and does not echo back the received value.
Steps to Reproduce
NSG_ID="ocid1.networksecuritygroup.oc1..example"
oci compute instance launch ... --nsg-ids "[$NSG_ID]"
Expected Behaviour
The error should include:
- The actual CLI flag the user typed (
--nsg-ids, not nsg_ids)
- The received input value so the user can see what was parsed
- A concrete example of valid input
Parameter '--nsg-ids' (received as '[ocid1.networksecuritygroup.oc1..example]')
must be valid JSON. Example: --nsg-ids '["ocid1.networksecuritygroup.oc1..example"]'
Actual Behaviour
Parameter 'nsg_ids' must be in JSON format.
For help with formatting JSON input see our documentation here: https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/cliusing.htm#ManagingCLIInputandOutput
Problems:
- The error says
nsg_ids (Python internal name) but the user typed --nsg-ids.
- The received value is not shown, making it hard to see what Bash actually parsed.
- The user is sent to external documentation instead of getting an inline example.
Context
This is a common stumbling block for Bash users. The safe pattern for embedding variables in JSON array parameters is non-obvious:
# ❌ Bash strips the inner quotes; fails
--nsg-ids "[$NSG_ID]"
# ✅ Backslash-escaped inner quotes; works
--nsg-ids "[\"$NSG_ID\"]"
The existing error message's source code is in src/oci_cli/cli_util.py:
sys.exit('Parameter {!r} must be in JSON format.\nFor help with formatting JSON input ...'.format(parameter_name))
Suggested Fix
Include the received input in the error message so users can see exactly what was parsed:
sys.exit('Parameter {!r} (received as {!r}) must be valid JSON.\nExample: --nsg-ids \'["ocid1.networksecuritygroup..."]\'\nFor more help see: https://docs.cloud.oracle.com/ias/Content/API/SDKDocs/cliusing.htm#ManagingCLIInputandOutput'.format(parameter_name, user_input))
Also consider mapping the internal parameter name back to the CLI flag name (e.g., nsg_ids → --nsg-ids) for user-facing output.
Description
When passing complex JSON parameters (
--nsg-ids,--metadata,--defined-tags,--shape-config, etc.) with invalid JSON, the error message is opaque: it uses the internal Python parameter name (lisp_case) instead of the CLI flag the user typed, and does not echo back the received value.Steps to Reproduce
Expected Behaviour
The error should include:
--nsg-ids, notnsg_ids)Actual Behaviour
Problems:
nsg_ids(Python internal name) but the user typed--nsg-ids.Context
This is a common stumbling block for Bash users. The safe pattern for embedding variables in JSON array parameters is non-obvious:
The existing error message's source code is in
src/oci_cli/cli_util.py:Suggested Fix
Include the received input in the error message so users can see exactly what was parsed:
Also consider mapping the internal parameter name back to the CLI flag name (e.g.,
nsg_ids→--nsg-ids) for user-facing output.