mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-08-21 06:33:17 +00:00
Coerce malformed <email> in aggregate report metadata to None (#740)
xmltodict turns stray angle brackets in <email> (e.g. "<bad-xml@bad-xml.net>") into a nested dict, which then flows through parse_aggregate_report_xml as the org_email value. Parsing succeeds, but Elasticsearch / OpenSearch reject the document at index time because the org_email mapping is text — observed as document_parsing_exception / mapper_parsing_exception with a "{#text=..., bad-xml=null}" preview. When report_metadata["email"] comes back as a dict, log it at debug and discard. The rest of the report still ingests with org_email=None instead of failing the whole document downstream. Co-authored-by: Sean Whalen <seanthegeek@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Sean Whalen
Claude Opus 4.7
parent
f3a2e894e0
commit
44fd1aa555
@@ -729,6 +729,12 @@ def parse_aggregate_report_xml(
|
||||
|
||||
report = xmltodict.parse(xml)["feedback"]
|
||||
report_metadata = report["report_metadata"]
|
||||
if isinstance(report_metadata.get("email"), dict):
|
||||
logger.debug(
|
||||
"Discarding malformed <email> in report_metadata: %r",
|
||||
report_metadata["email"],
|
||||
)
|
||||
report_metadata["email"] = None
|
||||
schema = "draft"
|
||||
if "version" in report:
|
||||
schema = report["version"]
|
||||
|
||||
Reference in New Issue
Block a user