fix(executor): narrow final-drain except to Exception (S5754) #75
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "Claude/backup-script:fix/issue-23-S5754-executor-bare-except"
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 #23
Problem
SonarQube rule S5754 flags the
except BaseException as e:atcore/executor.py:75(inside thefinallyofExecutor.run()) asswallowing every exception class — including
SystemExitandKeyboardInterrupt— without reraising. That defeats the SignalManagerescalation path: if a second SIGTERM landed during
signal_mgr.drain(),the resulting
SystemExitwould be caught here, logged asexecutor.final_drain_failed, and then the run would carry on as ifnothing had happened.
Every other
exceptin this file (_run_step_safe,_rollback_prior_steps,_ensure_destination_healthy) already narrows toExceptionfor exactlythis reason, with an inline comment.
Fix
Narrow the offending
exceptfromBaseExceptiontoException, matchingthe convention used three other places in the same module. Add the same
rationale comment so the next reader sees the consistent pattern.
Behaviour for ordinary drain bugs is unchanged: log a warning, record
finished_at, return the report. Behaviour for signal-driven aborts isrestored: the SystemExit propagates out of
run()and reaches thesignal-handler path.
Verification
pytest -q tests/unit/— all 211 tests pass (no test asserted theswallow-everything behaviour because none should have).
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.