feat(q1): D2 - try/flag PDF redaction failure in process_pdf
Étape D2 du sprint Q-1 (sous-commit 2/3 pour process_pdf) : Avant : try/except Exception: pass sur redact_pdf_vector → le PDF n'était pas généré mais l'opérateur n'en savait rien. Maintenant : - log.warning systématique de l'échec (rétro-compat : même si quarantine_mgr is None, on log) - Si quarantine_mgr fourni : flag pdf_redaction_failed (severity=partial) - Le texte .pseudonymise.txt est déjà sorti avant ce bloc, donc on ne raise pas — le doc sort en quarantaine partielle propre Le fallback raster + copie texte en quarantaine pour autoportance arrivent en D3. Rétro-compat préservée : les appels actuels sans quarantine_mgr voient seulement une nouvelle ligne de log.warning au lieu du silence. Ref: docs/coordination/inbox/for-dom/2026-05-29_consolide_pseudocode-Q1-v2.md §1 cas #6, §3 Décision A Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4673,8 +4673,20 @@ def process_pdf(
|
|||||||
try:
|
try:
|
||||||
redact_pdf_vector(pdf_path, anon.audit, vec_path, ocr_word_map=ocr_word_map)
|
redact_pdf_vector(pdf_path, anon.audit, vec_path, ocr_word_map=ocr_word_map)
|
||||||
outputs["pdf_vector"] = str(vec_path)
|
outputs["pdf_vector"] = str(vec_path)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
# Q-1 D2 : ne plus avaler silencieusement. Le texte (.pseudonymise.txt)
|
||||||
|
# est déjà sorti avant ce bloc — donc on log + flag quarantaine PDF
|
||||||
|
# (severity=partial). Le fallback raster + copie texte arrivent en D3.
|
||||||
|
log.warning("PDF vector redaction failed for %s: %s", pdf_path.name, e)
|
||||||
|
if quarantine_mgr is not None:
|
||||||
|
quarantine_mgr.flag(
|
||||||
|
doc_name=pdf_path.stem,
|
||||||
|
reason="pdf_redaction_failed",
|
||||||
|
detail=str(e),
|
||||||
|
severity="partial",
|
||||||
|
exc=e,
|
||||||
|
)
|
||||||
|
# Note : pas de raise — texte anonymisé déjà disponible, partial OK
|
||||||
if also_make_raster_burn and fitz is not None:
|
if also_make_raster_burn and fitz is not None:
|
||||||
ras_path = out_dir / f"{base}.redacted_raster.pdf"
|
ras_path = out_dir / f"{base}.redacted_raster.pdf"
|
||||||
redact_pdf_raster(pdf_path, anon.audit, ras_path, ogc_label=ogc_label, ocr_word_map=ocr_word_map)
|
redact_pdf_raster(pdf_path, anon.audit, ras_path, ogc_label=ogc_label, ocr_word_map=ocr_word_map)
|
||||||
|
|||||||
Reference in New Issue
Block a user