fix(letters): log extraction errors in /api/letters/{id}/extract#14
Open
aircode610 wants to merge 5 commits into
Open
fix(letters): log extraction errors in /api/letters/{id}/extract#14aircode610 wants to merge 5 commits into
aircode610 wants to merge 5 commits into
Conversation
Adds a GitHub Actions workflow that triggers on issue creation and automatically applies labels (type, component, priority, security) and assigns team members based on keyword matching in the issue title and body. Also creates 8 new repo labels for components, priorities, and security. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The generic except handler in extract_letter silently swallowed exceptions:
it raised KlarHTTPException (caught by klar_exception_handler) but never
logged the original traceback. The misleading comment claimed the error
would be "Logged by unhandled_exception_handler" — but that handler is
never reached. This made production debugging impossible for extraction
failures on this endpoint.
Added logger.exception() to the generic handler and logger.info() to the
typed PdfRenderError/ExtractionError handlers, matching what public.py
already does. Also added 3 regression tests for the /api/letters/{id}/extract
path (24 total, all passing).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The CI workflow (lint.yml) was missing from this branch, so PR #14 had zero status checks. Add it back with both the ruff lint job and a new tests job that runs pytest against backend/tests/. Also fix a minor ruff format violation in test_scanned_pdf_graceful.py. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…xtraction-logging
The CI workflow was failing for two reasons: 1. pytest-asyncio was not installed, causing all 14 async tests to fail with "async def functions are not natively supported" 2. ruff found 22 lint errors (unused imports, f-strings without placeholders, E402 import ordering, unused variables) in the merged code (PR branch + main) Adds pytest-asyncio to the CI install step, fixes all ruff lint errors (removing unused imports/variables, reordering imports in public.py), and applies ruff format across the codebase. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/letters/{id}/extractendpoint's genericexcept Exceptionhandler silently swallowed errors — it raisedKlarHTTPException(caught byklar_exception_handler) but never logged the original traceback. The old comment misleadingly claimed it would be "Logged byunhandled_exception_handler" — that handler is never reached.logger.exception()to the generic handler andlogger.info()to the typedPdfRenderError/ExtractionErrorhandlers inletters.py, matching whatpublic.pyalready does./api/letters/{id}/extractpath (scanned PDF →EXTRACTION_FAILED, corrupt PDF →PDF_RENDER_FAILED, unexpected error → generic 502 without leaking internals). 24/24 tests passing,ruff-clean.Context
PR #13 fixed the core issue #8 crash across three entry points (
POST /letters, SSE/process, sync/extract). The typed error handling was applied to all three, but logging was only added topublic.pyandorchestrator.py— theletters.pyhandler was left with a silentexcept Exceptionthat makes production debugging impossible on the/api/letters/{id}/extractroute.Test plan
backend/tests/test_scanned_pdf_graceful.py)ruffclean on both modified filesExtractionError→ 502 EXTRACTION_FAILED,PdfRenderError→ 502 PDF_RENDER_FAILED, genericRuntimeError→ 502 without leaking secrets🤖 Generated with Claude Code