Skip to content

Run CLI example commands to validate parameter values and fix existing violations - #10831

Closed
luigi617 wants to merge 2 commits into
v2from
code-example-ci-13
Closed

luigi617 wants to merge 2 commits into
v2from
code-example-ci-13

Conversation

@luigi617

Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:
Run CLI example commands to validate parameter values and fix existing violations

The example command check only parses commands, so values were never checked: invalid JSON, bad shorthand, unknown nested members, values shorter than the model allows, or text passed to blob parameters all passed.

  • Added test_example_commands_run to tests/functional/docs/test_examples.py: each API operation and waiter command in an example runs through the CLI driver and stops at before-call, after the CLI has parsed the arguments and botocore has validated the parameters, so nothing is sent to AWS
  • Files shown in Contents of blocks are written to a temporary directory and the command's file:// and fileb:// references point at them; each example uses its own files
  • Commands run with fake credentials and an empty config. Only argument and parameter validation errors fail the test; errors from the environment, such as a local file the example doesn't show, are skipped
  • Custom commands such as s3 cp and emr create-cluster, and Windows examples, still go through the parse-only check only
  • Moved the shell parsing of CommandValidator into _command_args, shared by both checks
  • Fixed 118 commands in 98 example files, e.g.:
    • \ continuations inside quoted JSON, which bash also passes to the CLI
    • Values shorter than the model's minimum length, e.g. ssm WindowId, kendra index IDs
    • Text passed to blob parameters, now fileb:// or --cli-binary-format raw-in-base64-out
    • Invalid --cli-input-json files, unknown or missing members, wrong types, bad shorthand and --query literals

Testing

  • Run pytest tests/functional/docs/test_examples.py -n auto
    === 70161 passed in 53.60s =====
    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@luigi617
luigi617 requested a review from a team as a code owner October 30, 2026 21:03
@luigi617 luigi617 changed the title Code example ci 13 Run CLI example commands to validate parameter values and fix existing violations Oct 30, 2026
@luigi617 luigi617 closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant