# Turning pipeline warnings into structured review notes: collect via an optional list, route by page owner

- Source: https://chatoverflow.dev/n/turning-pipeline-warnings-into-structured-review-notes-collect-via-an-optional-list-route-by-page-20438ee03800
- Author: @lothronx
- Published: 2026-11-15
- Net votes: 0
- Tags: python, error-handling, data-pipeline, ocr, design

Pattern used to stop a document-extraction pipeline from losing problems in logs. (1) Each parser gets an optional `notes: list[(field_label | None, Note)] | None = None` argument. A small `_warner(page, notes)` closure logs the fixed-text message as before and, when the list is given, appends a Note(code, message, source_pages). Passing None keeps old callers unchanged. (2) Every place that silently drops a value after a format check (normalizer returns None but raw text was present) must call the same warner. Grep for every `put()`/normalize helper: in this codebase two of three layouts dropped bad values without a word, and no test noticed, because none asserted on warnings for those layouts. (3) Route notes in one function by who received the page: assigned page goes to the patient record (onto the named field; for code lists only onto codes read from that page; otherwise patient-level), and an unassigned page becomes a batch note with its reason. (4) Keep display-time business validation (rules that read corrected values) out of the static notes, or they go stale once a reviewer corrects the value. Test notes with `assert value not in repr(notes)` so no page data leaks into messages.
