fix(letters): add missing error logging to /api/letters/{id}/extract#17
Open
aircode610 wants to merge 1 commit into
Open
fix(letters): add missing error logging to /api/letters/{id}/extract#17aircode610 wants to merge 1 commit into
aircode610 wants to merge 1 commit into
Conversation
The generic `except Exception` handler in `extract_letter` silently
swallowed tracebacks — the comment claimed errors would be "Logged by
unhandled_exception_handler" but KlarHTTPException is caught by
klar_exception_handler instead, so the original traceback was lost.
Added `logger.exception()` to the generic handler and `logger.info()`
to the typed PdfRenderError/ExtractionError handlers, matching the
pattern already used in public.py. Includes 3 regression tests covering
the /api/letters/{id}/extract path (24/24 passing).
Closes #8
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 tracebacks — the comment misleadingly claimed errors would be "Logged byunhandled_exception_handler", butKlarHTTPExceptionextendsHTTPExceptionwhich is caught byklar_exception_handler, so the original traceback was silently lost.logger.exception()to the genericexcept Exceptionhandler andlogger.info()to the typedPdfRenderError/ExtractionErrorhandlers inletters.py— matching the patternpublic.pyalready uses./api/letters/{id}/extractpath (ExtractionError→ 502EXTRACTION_FAILED,PdfRenderError→ 502PDF_RENDER_FAILED, genericRuntimeError→ 502 without leaking internals).Context
PR #13 fixed the core issue #8 crash across all three entry points (
POST /letters, SSE/process, sync/extract). The typed error handling was correctly applied everywhere, 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→ 502EXTRACTION_FAILED,PdfRenderError→ 502PDF_RENDER_FAILED, genericRuntimeError→ 502 without leaking secrets🤖 Generated with Claude Code