Missing validation for max_attempts parameter in retry_service_operation #10574

Open
opened 2026-04-18 17:29:17 +00:00 by HAL9000 · 0 comments
Owner

Metadata

  • Commit: Latest commit in repository
  • Branch: main

Background and Context

The retry_service_operation function in src/cleveragents/core/retry_service_patterns.py does not validate the max_attempts parameter. This parameter controls the maximum number of retry attempts before giving up. Without validation, invalid values can cause unexpected retry behavior or failures in the tenacity library.

Expected Behavior

The retry_service_operation function should validate that max_attempts is a positive integer (>= 1) and raise a ValueError with a clear error message if it is not. This ensures the retry logic behaves predictably and fails fast with meaningful feedback.

Actual Behavior

No validation is performed on the max_attempts parameter. If set to 0 or a negative value, the retry logic behaves unexpectedly:

  • A value of 0 means no attempts will be made
  • Negative values could cause undefined behavior in the tenacity library's stop_after_attempt() function

Acceptance Criteria

  • The retry_service_operation function validates that max_attempts is a positive integer (>= 1)
  • A ValueError is raised with a descriptive message if max_attempts is invalid
  • Unit tests verify validation for edge cases: 0, -1, and valid positive values
  • Error message clearly indicates the requirement (e.g., "max_attempts must be >= 1")

Subtasks

  • Add validation logic to retry_service_operation function
  • Create unit tests for invalid max_attempts values (0, -1, etc.)
  • Create unit tests for valid max_attempts values
  • Update function docstring to document the validation requirement
  • Verify no other retry functions have the same issue

Definition of Done

  • Validation is implemented and prevents invalid max_attempts values
  • All unit tests pass with >= 97% coverage
  • Code review approved
  • Changes merged to main branch

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit**: Latest commit in repository - **Branch**: main ## Background and Context The `retry_service_operation` function in `src/cleveragents/core/retry_service_patterns.py` does not validate the `max_attempts` parameter. This parameter controls the maximum number of retry attempts before giving up. Without validation, invalid values can cause unexpected retry behavior or failures in the tenacity library. ## Expected Behavior The `retry_service_operation` function should validate that `max_attempts` is a positive integer (>= 1) and raise a `ValueError` with a clear error message if it is not. This ensures the retry logic behaves predictably and fails fast with meaningful feedback. ## Actual Behavior No validation is performed on the `max_attempts` parameter. If set to 0 or a negative value, the retry logic behaves unexpectedly: - A value of 0 means no attempts will be made - Negative values could cause undefined behavior in the tenacity library's `stop_after_attempt()` function ## Acceptance Criteria - [ ] The `retry_service_operation` function validates that `max_attempts` is a positive integer (>= 1) - [ ] A `ValueError` is raised with a descriptive message if `max_attempts` is invalid - [ ] Unit tests verify validation for edge cases: 0, -1, and valid positive values - [ ] Error message clearly indicates the requirement (e.g., "max_attempts must be >= 1") ## Subtasks - [ ] Add validation logic to `retry_service_operation` function - [ ] Create unit tests for invalid `max_attempts` values (0, -1, etc.) - [ ] Create unit tests for valid `max_attempts` values - [ ] Update function docstring to document the validation requirement - [ ] Verify no other retry functions have the same issue ## Definition of Done - Validation is implemented and prevents invalid `max_attempts` values - All unit tests pass with >= 97% coverage - Code review approved - Changes merged to main branch --- **Automated by CleverAgents Bot** Agent: new-issue-creator
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#10574
No description provided.