Skip to content

fix: stop swallowing extraction errors in background task#173

Merged
BKDDFS merged 3 commits into
mainfrom
fix/surface-extraction-traceback
Jun 6, 2026
Merged

fix: stop swallowing extraction errors in background task#173
BKDDFS merged 3 commits into
mainfrom
fix/surface-extraction-traceback

Conversation

@BKDDFS

@BKDDFS BKDDFS commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Problem

ExtractorManager.__run_extractor wrapped extractor.process() in a broad except Exception that logged a single line ("Extraction failed with error") and swallowed the exception. The real traceback was lost.

This actively hid a failure: when an extraction crashed, _active_extractor was reset to None, so /v2/status reported the service as idle/done even though nothing was produced. The e2e tests could only observe the symptom (No output files were created) with no way to see the underlying cause.

Change

Remove the except block. Keep finally.

  • Extraction runs in a FastAPI BackgroundTask, so the exception propagates to Starlette and is logged with a full traceback in the container logs.
  • The finally block still resets _active_extractor, so a crashed extraction does not brick the single-extractor lock (no permanent 409).
  • No client-facing behavior change: the response (started) is already sent before the background task runs, so there was never a 500 to lose.

Result

Background-task failures are now diagnosable from container logs instead of being silently discarded.

BKDDFS and others added 3 commits June 6, 2026 13:49
Remove the broad `except Exception` in ExtractorManager.__run_extractor.
It only logged a one-line message and suppressed the exception, hiding the
real traceback. Since extraction runs in a FastAPI BackgroundTask, the
exception now propagates to Starlette and is logged with full traceback in
the container logs, making failures diagnosable.

The `finally` block still resets _active_extractor, so a crashed extraction
no longer requires the except to avoid bricking the single-extractor lock.
Update test_run_extractor to reflect the new contract: __run_extractor no
longer swallows exceptions. The test now asserts the exception propagates
(pytest.raises) and that the finally block still resets _active_extractor,
so a crashed extraction does not leave the single-extractor lock stuck.
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
perfectframe/extractor_manager.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BKDDFS BKDDFS merged commit 2876fcc into main Jun 6, 2026
9 checks passed
@BKDDFS BKDDFS deleted the fix/surface-extraction-traceback branch June 6, 2026 12:01
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