Skip to content

Expose --delay and --max-attempts for wait commands (#1295)#10224

Open
minjcho wants to merge 3 commits intoaws:v2from
minjcho:expose-waiter-delay-max-attempts
Open

Expose --delay and --max-attempts for wait commands (#1295)#10224
minjcho wants to merge 3 commits intoaws:v2from
minjcho:expose-waiter-delay-max-attempts

Conversation

@minjcho
Copy link
Copy Markdown

@minjcho minjcho commented Apr 15, 2026

Issue #, if available:
Fixes #1295

Description of changes:

  • Add --delay and --max-attempts arguments to waiter commands.
  • Pass the provided values through WaiterConfig when invoking waiter.wait().
  • Update waiter help text to document the new options.
  • Add unit coverage for argument parsing, help output, and waiter config injection.

Description of tests:

  • Added unit tests covering argument parsing, help output, and waiter config injection.
  • Ran python -m pytest tests/unit/customizations/test_waiters.py -q — all pass.
  • Succeeded manual testing described below.

Manual testing:

Verified the new flags appear in the generated help output:

aws ec2 wait instance-running help

I confirmed that [--delay <value>] and [--max-attempts <value>] are listed in the synopsis and documented in the options section.

Then I ran:

aws ec2 wait instance-running --instance-ids <YOUR_INSTANCE_ID> --delay 5 --max-attempts 10

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@minjcho
Copy link
Copy Markdown
Author

minjcho commented Apr 17, 2026

Added input validation for --delay and --max-attempts

Since other CLI params don't check non-positive values at the CLI layer (they rely on botocore's ParamValidator or the AWS server to reject them), I initially didn't add validation here either.

But I found that WaiterConfig is a special case — it's popped from kwargs via kwargs.pop('WaiterConfig', {}) before reaching ParamValidator or the API server, and consumed locally in time.sleep() and a loop counter. No layer validates these values:

  • --delay -1ValueError: sleep length must be non-negative (Python runtime error from time.sleep(-1))
  • --delay 0 → rapid-fire API calls with no sleep interval
  • --max-attempts 0 or -1 → polls once, then immediately raises WaiterError

Added validation in WaiterArgument.add_to_params matching the waiter JSON schema constraints (delay >= 0, maxAttempts >= 1 from botocore/tests/functional/test_waiter_config.py):

$ aws ec2 wait instance-running --instance-ids i-123 --delay -1
aws: [ERROR]: --delay must be a non-negative integer, got -1

$ aws ec2 wait instance-running --instance-ids i-123 --max-attempts 0
aws: [ERROR]: --max-attempts must be a positive integer, got 0

Added 7 unit tests covering rejection and acceptance boundaries.

I'll also file a separate issue on botocore for adding the same validation in Waiter.wait(), since boto3 users are equally affected.

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