fix(retry): remove always-False identity check in run_with_retry (S5727) #68
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "Claude/backup-script:fix/issue-29-S5727-retry-identity-check"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #29
Problem
SonarQube rule S5727 flags
if last_exc is not None:inrun_with_retry(core/retry.py:126) as a constant comparison —
last_excis initialized toNoneon line 121 and never reassigned inside the loop, so the identitycheck is always False and the body is unreachable. The whole branch is dead
code, and the
raise last_excit gated would have raisedNone(theadjacent S5632 finding, issue #30).
Fix
Delete the dead-code fallback entirely. With
reraise=Trueon bothnetwork_retrying()andkuma_retrying(), the tenacity iterator alreadyre-raises the final exception out of the
with attempt:block, so thepost-loop code is reached only if the policy yielded zero attempts (a
misconfiguration). Keep that defensive case as an unconditional
raise RuntimeError(...)and document why the previous block was dead.Verification
pytest -q tests/unit/— all 211 tests pass, including the regressionsuite in
tests/unit/test_retry_policy.pywhich exercises the loop onboth retried and non-retried exception types.
mypy --strict src/gardien/core/— clean (10 source files, no issues).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.