Skip to content

Add validation for WaiterConfig Delay and MaxAttempts values (#3674)#3675

Open
minjcho wants to merge 1 commit intoboto:developfrom
minjcho:fix/waiter-config-validation
Open

Add validation for WaiterConfig Delay and MaxAttempts values (#3674)#3675
minjcho wants to merge 1 commit intoboto:developfrom
minjcho:fix/waiter-config-validation

Conversation

@minjcho
Copy link
Copy Markdown

@minjcho minjcho commented Apr 17, 2026

Issue #, if available:
Fixes #3674

Description of changes:

Waiter.wait() now validates Delay and MaxAttempts in WaiterConfig
before entering the polling loop.

Previously, invalid values caused confusing Python runtime errors or
silently broken behavior:

  • Delay: -1 -> ValueError from time.sleep()
  • MaxAttempts: 'abc' -> TypeError from >= comparison
  • Delay: 0 -> rapid-fire API calls with no sleep
  • MaxAttempts: 0 -> polls once, then immediately raises WaiterError

Invalid values now raise WaiterConfigError with a clear message before
any API call is made. This is consistent with existing waiter config
validation (unsupported version, unknown matcher).

Validation rules:

  • Delay: non-negative number (int or float, not bool)
  • MaxAttempts: positive integer (>= 1, not bool or float)

Note: this intentionally validates against Python built-in numeric types
only (int, float), consistent with botocore's existing isinstance-based
validation patterns. Third-party numeric types (e.g. numpy.int64) that
previously worked implicitly via duck typing will now need to be converted
to native Python types before being passed in WaiterConfig.

Description of tests:

Added 11 unit tests in tests/unit/test_waiters.py:

Rejection cases (9):

  • Delay: -1 (negative)
  • Delay: 'fast' (non-numeric)
  • Delay: None
  • Delay: True (bool)
  • MaxAttempts: 0 (zero)
  • MaxAttempts: -1 (negative)
  • MaxAttempts: 'abc' (non-integer)
  • MaxAttempts: True (bool)
  • MaxAttempts: 1.5 (float)

Acceptance cases (2):

  • Delay: 0, MaxAttempts: 1 (minimum valid)
  • Delay: 0.5, MaxAttempts: 1 (float delay)

All rejection tests verify operation_method.assert_not_called() to confirm
no API call is made before validation fails.

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

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.

Waiter.wait() does not validate WaiterConfig values

1 participant