fix(review): warn (not debug) on shadow-classify failure; tidy pymupdf usage
Address PR #855 round 2: - 🔴 _shadow_classify swallowed all exceptions at DEBUG, so a systematic failure (pymupdf bug, memory pressure) is invisible at LOG_LEVEL=INFO and trips SonarQube S2221/S5754. Log at WARNING instead (still best-effort -- indexing is unaffected). - classifier: use `with pymupdf.open(...) as doc` instead of manual try/finally. - tests: release the Pixmap's native memory (del pix) in the image fixtures. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
0347e96679
commit
4bdb0bc6d6
@@ -186,7 +186,14 @@ async def _shadow_classify(content: bytes, content_type: str, file_path: str) ->
|
||||
c.mean_text_quality,
|
||||
)
|
||||
except Exception:
|
||||
logger.debug("Tier-0 classification failed for %s", file_path, exc_info=True)
|
||||
# Best-effort: shadow classification must never break indexing, but log
|
||||
# at WARNING (not DEBUG) so a systematic failure -- a pymupdf bug, memory
|
||||
# pressure on every PDF -- stays visible at the production LOG_LEVEL=INFO.
|
||||
logger.warning(
|
||||
"Tier-0 classification failed for %s (shadow mode, indexing unaffected)",
|
||||
file_path,
|
||||
exc_info=True,
|
||||
)
|
||||
|
||||
|
||||
async def process_document(
|
||||
|
||||
Reference in New Issue
Block a user