Harden historical sorter header parsing

The prompts used to arrive at this change since the previous commit

User asked to check the audit log in the current directory before reordering the real mailbox.

Any special observations that may be relevant for version management for this version. Be brief.

The inspected log was a partial real backup run, not a hans audit. Header parsing now skips non-bytes FETCH payloads instead of aborting. verplaats_log.json and plan.md were left unstaged.
This commit is contained in:
2026-07-05 11:48:09 +02:00
parent d0e78e728a
commit edcad4560c
2 changed files with 30 additions and 0 deletions
+26
View File
@@ -372,6 +372,19 @@ def stap2_bronmappen_routing(session: ImapSession, log: dict, dry: bool):
mislukt += 1
log_failure(log, "stap2", bron, uid, None, "fetch_header", status, data)
continue
if not isinstance(raw_header, bytes):
mislukt += 1
log_failure(
log,
"stap2",
bron,
uid,
None,
"fetch_header_type",
status,
f"expected bytes, got {type(raw_header).__name__}",
)
continue
msg = email.message_from_bytes(raw_header)
from_raw = decode_hdr(msg.get("From", ""))
@@ -502,6 +515,19 @@ def stap3_facturen(session: ImapSession, log: dict, dry: bool):
mislukt += 1
log_failure(log, "stap3", bron, uid, None, "fetch_header", status, data)
continue
if not isinstance(raw_header, bytes):
mislukt += 1
log_failure(
log,
"stap3",
bron,
uid,
None,
"fetch_header_type",
status,
f"expected bytes, got {type(raw_header).__name__}",
)
continue
msg = email.message_from_bytes(raw_header)
date_str = msg.get("Date", "")