Skip to content

fix(execution): catch BaseException from task code - #934

Merged
tobiasraabe merged 3 commits into
mainfrom
codex/catch-baseexception-in-tasks
Aug 15, 2026
Merged

tobiasraabe merged 3 commits into
mainfrom
codex/catch-baseexception-in-tasks

Conversation

@tobiasraabe

Copy link
Copy Markdown
Member

Summary

  • catch BaseException at the user-task execution boundary
  • retain the dedicated KeyboardInterrupt branch and existing pytask control-flow handling
  • turn raw SystemExit, including SystemExit(0), into an ordinary failed task report
  • verify unrelated execution, descendant skipping, and unconfiguration

Root cause

The task protocol caught Exception, but SystemExit inherits directly from BaseException. A task calling sys.exit(0) therefore escaped report creation and cleanup and could terminate pytask with a successful process status.

Impact

Raw SystemExit from task code now follows normal task failure semantics. Its exit code remains available on the reported exception, unrelated tasks continue, descendants skip, and the build returns pytask's failed-build exit code.

Validation

  • uv run --group test pytest --snapshot-warn-unused: 935 passed, 39 skipped, 4 xfailed
  • uv run --group test pytest tests/test_execute.py -q: 57 passed, 1 xfailed
  • uv run --group typing --group test --isolated ty check --python-platform linux: passed
  • project-locked uv run ruff check .: passed
  • project-locked ruff format --check for changed files: passed
  • all non-Ruff pre-commit hooks: passed

The repository's just recipes cannot locate their configured shell on this Windows checkout. The pre-commit Ruff 0.16 hook also reports new baseline rules across untouched main, while the project lock provides Ruff 0.15.16. This PR was checked with the project-locked Ruff version and does not alter lint configuration.

@tobiasraabe tobiasraabe changed the title Catch BaseException from task code fix(execution): catch BaseException from task code Aug 2, 2026
@tobiasraabe
tobiasraabe marked this pull request as ready for review August 2, 2026 18:45
@tobiasraabe
tobiasraabe enabled auto-merge August 15, 2026 08:01
@tobiasraabe
tobiasraabe added this pull request to the merge queue Aug 15, 2026
Merged via the queue into main with commit fb5b59d Aug 15, 2026
23 checks passed
@tobiasraabe
tobiasraabe deleted the codex/catch-baseexception-in-tasks branch August 15, 2026 08:11
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