Skip to content

fix: correct missing f-string and off-by-one retry guard#237

Open
Nicknamess96 wants to merge 1 commit intoentrius:testfrom
Nicknamess96:fix/missing-fstring-and-retry-off-by-one
Open

fix: correct missing f-string and off-by-one retry guard#237
Nicknamess96 wants to merge 1 commit intoentrius:testfrom
Nicknamess96:fix/missing-fstring-and-retry-off-by-one

Conversation

@Nicknamess96
Copy link

Summary

Two bug fixes found via code review:

1. Missing f-string prefix in forward.py (line 259)

Bug: The log message in issues_competition() uses a plain string instead of an f-string:

'***** Issue Bounties Complete: processed {len(active_issues)} issues (no state changes) *****'

This prints the literal text {len(active_issues)} instead of the actual count.

Fix: Added the f prefix so the variable is interpolated correctly.

2. Off-by-one in get_pull_request_file_changes() retry guard (lines 279, 289)

Bug: The condition attempt < max_attempts is always True inside a range(max_attempts) loop, causing an unnecessary time.sleep() (up to 20s) after the last failed attempt before the function returns. This does not match the pattern used in execute_graphql_query() and get_github_graphql_query(), which both correctly use attempt < (max_attempts - 1).

Fix: Changed to attempt < max_attempts - 1 in both the HTTP error and RequestException branches.

Testing

  • Updated test_gives_up_after_three_attempts: corrected sleep count assertion from 3 to 2
  • Updated test_exponential_backoff_timing: corrected expected delays from [5, 10, 20] to [5, 10]
  • Added test_no_sleep_after_final_http_error: verifies no sleep after final HTTP error
  • Added test_no_sleep_after_final_connection_error: verifies no sleep after final connection timeout

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the repository's coding conventions
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally
  • My changes generate no new warnings

…ithub_api_tools.py

- Add missing f-prefix to log message in issues_competition() so
  {len(active_issues)} is interpolated instead of printed literally
- Fix off-by-one in get_pull_request_file_changes() retry guards:
  change `attempt < max_attempts` to `attempt < max_attempts - 1`
  to avoid unnecessary sleep after the final failed attempt
- Update existing tests and add new tests verifying no sleep occurs
  after the last retry attempt
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