generated from john/python-template
5.1 KiB
5.1 KiB
Step 7 Results: Error Handling Standardization and Operational Visibility
Summary
Step 7 was implemented across the MVP runtime boundaries with a shared error taxonomy, actionable UI error surfacing, worker failure normalization, and API error envelope handling.
All required validation gates in docs/step7.md were executed and passed.
Scope Delivered
Implemented
- Shared application error contract and taxonomy
- Service-layer error normalization (upload + transcription)
- UI error presentation helpers with suggested actions and error references
- Worker failure persistence format with category/suggestion/error_id markers
- API exception handlers for structured error responses
- Targeted tests for new error contract behavior
Not implemented in this step
- External lane execution (
-m external) was not required for Step 7 completion and was not run in this pass.
Files Added
src/transcription/errors.pysrc/transcription/api/errors.pysrc/transcription/ui/error_presenter.pytests/test_errors.pytests/api/test_error_responses.pydocs/step7.md
Files Updated
src/transcription/app.pysrc/transcription/services/upload.pysrc/transcription/services/transcription.pysrc/transcription/ui/upload_page.pysrc/transcription/ui/jobs_page.pysrc/transcription/worker.pytests/services/test_upload.pytests/services/test_transcription.pytests/services/test_worker.pytests/integration/test_pipeline_flow.pyuv.lock
Implementation Notes by Phase
Phase A/B (Foundation)
- Added
ErrorCategoryenum andAppErrorbase type insrc/transcription/errors.py. - Added helper utilities:
new_error_id()build_error_envelope(...)classify_unexpected_error(...)format_error_detail(...)
Phase C (Service/Provider normalization)
UploadErrornow extendsAppErrorand includes category/suggestion/retriable metadata.PromptLoadErrorandTranscriptionErrornow extendAppError.- Provider failures are mapped with deterministic category semantics (auth/payload/provider-failure cases).
Phase D (UI visibility)
- Added
src/transcription/ui/error_presenter.py. - Upload and jobs pages now use centralized UI error rendering and summary helpers.
- UI error paths now include more visible/actionable guidance and reference IDs.
Phase E (Worker failure handling)
- Worker now normalizes exception handling into structured persisted
error_detailstrings with:- category marker
- suggestion marker
- error_id marker
- Logging now includes category/error_id context in failure paths.
Phase F (API envelope)
- Added
src/transcription/api/errors.pyand registered handlers in app factory. - AppError and unexpected exceptions now serialize to stable API envelopes with mapped status codes.
Validation Commands and Outcomes
All commands were executed with uv run python -m pytest ... and completed successfully.
uv run python -m pytest tests/test_errors.py -q✅uv run python -m pytest tests/services/test_upload.py -q✅uv run python -m pytest tests/services/test_transcription.py -q✅uv run python -m pytest tests/providers/test_openrouter.py -q✅uv run python -m pytest tests/services/test_worker.py -q✅uv run python -m pytest tests/integration/test_pipeline_flow.py -q✅uv run python -m pytest tests/api/test_error_responses.py -q✅uv run python -m pytest tests/ui/test_upload_page.py -q✅uv run python -m pytest tests/ui/test_jobs_page.py -q✅uv run python -m pytest -m "not external" -q✅uv run python -m pytest --collect-only -q✅uv run python -m pytest -m unit -q✅uv run python -m pytest -m integration -q✅uv run python -m pytest tests/integration/test_pipeline_flow.py -q✅uv run python -m pytest tests/ui/test_upload_page.py -q✅uv run python -m pytest tests/ui/test_jobs_page.py -q✅uv run python -m pytest -q✅
Observed warning (non-blocking): Starlette/FastAPI TestClient deprecation warning related to httpx package naming.
Policy Alignment Check (docs/error_handling.md)
Aligned items:
- Stable taxonomy categories are implemented.
- Unexpected errors are normalized.
- User-facing UI paths include actionable guidance and references.
- Worker persistence includes trace-friendly failure detail.
- API error responses are structured and category-aware.
Follow-up candidates:
- Add richer UI tests that validate rendered suggested-action content end-to-end (current tests focus helper/service contracts).
- Consider typed storage fields for error metadata instead of packed
error_detailstrings in a future schema revision.
Step 7 Definition of Done Status
- Shared error taxonomy implemented across MVP layers
- GUI error paths upgraded for visibility/actionability
- Worker failure persistence and log context standardized
- API error envelope handling added and tested
- Phase-level and full-suite validation gates passed
- Results documented in this report
Step 7 is complete.