Skip to content

fix(sdk): validate task retry counts and timeout in decorator guardrails#4117

Open
UGVicV wants to merge 15 commits into
orchestration-agent:mainfrom
UGVicV:fix/bounty-2324-retry-validation
Open

fix(sdk): validate task retry counts and timeout in decorator guardrails#4117
UGVicV wants to merge 15 commits into
orchestration-agent:mainfrom
UGVicV:fix/bounty-2324-retry-validation

Conversation

@UGVicV
Copy link
Copy Markdown

@UGVicV UGVicV commented May 25, 2026

Description

This PR resolves the issue where the @task decorator silently accepted negative retry counts and invalid timeout values, storing them in __task_config__ without validation. Schedulers could skip or repeat work based on invalid metadata.

Fix

  • Added type validation for retries: rejects non-integer types (including bool) with TypeError.
  • Added value validation for retries: rejects negative values with ValueError("retries must be non-negative").
  • Added type validation for timeout: rejects non-integer types (including bool) with TypeError.
  • Added value validation for timeout: rejects zero and negative values with ValueError("timeout must be a positive integer").
  • Validation runs at decorator definition time (not at call time), catching errors early.
  • Wrapped in try-except with logger.error() for robust error logging.
  • Fixed pre-existing PEP8 violations (all lines under 79 characters).
  • Removed unused imports (Any, Dict).

Verification (Proof)

Created new regression test file tests/test_sdk_decorators.py with 8 test cases:

  • test_valid_retries: Valid retries=3 stored correctly.
  • test_valid_zero_retries: Zero retries accepted.
  • test_negative_retries: Negative retries raises ValueError.
  • test_non_int_retries: String retries raises TypeError.
  • test_bool_retries: Boolean retries raises TypeError.
  • test_negative_timeout: Negative timeout raises ValueError.
  • test_zero_timeout: Zero timeout raises ValueError.
  • test_non_int_timeout: String timeout raises TypeError.

Test Execution Output

65 passed in 0.06s

Lint & Formatting Output

  • flake8 src/sdk/decorators.py tests/test_sdk_decorators.py -> Passed (0 errors/warnings)
  • git diff --check -> Passed (0 errors)

No secrets, tokens, or hidden context are included in the code.

Closes #2324.

Vic added 15 commits May 22, 2026 11:55
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.

[ Bounty $5k ] [ SDK ] Validate task retry counts — decorator guardrails

1 participant