Skip to content

fix: mark a run failed when it crashes instead of leaving it running (SECFOO-39) - #25

Merged
vsn411 merged 1 commit into
secfoo-com:mainfrom
karthickmk2001:fix/stuck-running-runs
Oct 3, 2026
Merged

vsn411 merged 1 commit into
secfoo-com:mainfrom
karthickmk2001:fix/stuck-running-runs

Conversation

@karthickmk2001

Copy link
Copy Markdown
Collaborator

Summary

Fixes SECFOO-39: a run that crashes stays running forever in secfoo list and the dashboard.

Cause: _run_single_skill() inserts the run as running (create_run) before the agent starts, and only complete_run() at the end moves it on. Any exception in between skipped complete_run() and left the row stuck: an adapter crash, a file write error, a report parser, or Ctrl+C. This was seen in the SECFOO-10 E2E, where a Copilot launch crash (WinError 2, since fixed in #23) left two runs at running permanently.

Fix: wrap that span in try/except BaseException:

  • The run is completed as failed, with its end time, duration, and the traceback as the stderr excerpt.
  • The exception is re-raised, so callers and the CLI behave exactly as before.
  • BaseException means Ctrl+C mid-run is recorded too.
  • _mark_run_crashed() never raises, so a failure while recording can't hide the original error.

Test plan

  • New test_a_run_that_crashes_is_marked_failed_not_left_running: an adapter raising FileNotFoundError must leave the run failed with finished_at set and the traceback saved, and the exception must still reach the caller.
  • Checked that the test catches the bug: against the old runner.py it fails with assert 'running' == 'failed'.
  • pytest: 729 passed, 5 failed. The 5 (test_cloud permissions and 4 architecture dashboard tests) fail the same way on main on Windows.
  • Rebased onto current main, including Make cost tracking a CI control: --fail-on, --max-cost, --json #19's severity counts on RunOutcome.

Not in this PR

Runs already stuck at running in existing databases aren't cleaned up. That could be a one-off UPDATE or a startup sweep if wanted.

🤖 Generated with Claude Code

…" (SECFOO-39)

create_run() inserts the row as 'running' and only complete_run() moves
it on, so any exception in between (adapter crash, disk error, a report
parser) left the run 'running' forever in `secfoo list` and the
dashboard. Found in the SECFOO-10 E2E, where a Copilot launch crash
left two runs stuck.

Wrap that span: on any exception (BaseException, so Ctrl+C is recorded
too) the run is completed as 'failed' with its end time and the
traceback as the stderr excerpt, then the exception is re-raised so
callers behave exactly as before. Closing out the row never raises, so
it can't mask the original error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@karthickmk2001
karthickmk2001 requested a review from vsn411 October 2, 2026 13:44
@vsn411
vsn411 merged commit 138452f into secfoo-com:main Oct 3, 2026
2 checks passed
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.

2 participants