Verifying parsedmarc changes
The runtime surface is the parsedmarc CLI; the library's stream APIs are
drivable via python -c through the public parsedmarc package.
Launch
# No config file → results print as JSON to stdout. --offline skips DNS/downloads.
GITHUB_ACTIONS=true .venv/bin/python -m parsedmarc.cli --offline <sample files>
- Do not use
-c ci.inilocally: it points athttp://localhost:9200Elasticsearch (a CI service container) and retries for ~75s before failing. GITHUB_ACTIONS=trueskips live DNS lookups.--debugsurfaces per-file parse warnings/errors (invalid reports are otherwise dropped silently from the JSON).
Good sample inputs (all under samples/)
aggregate/rfc9990-sample.xml— RFC 9990 aggregate reportaggregate/*.xml.zip,aggregate/*.xml.gz— archive extraction pathsfailure/dmarc_ruf_report_linkedin.eml— failure (RUF) report with an embedded rfc822 sample (exercisesutils.parse_email)aggregate/invalid_xml.xml— recovered via lxml, parses witherrorsset
Stream API (stdin is genuinely non-seekable when piped)
cat samples/aggregate/*.xml.gz | .venv/bin/python -c \
"import sys, parsedmarc; print(parsedmarc.extract_report(sys.stdin.buffer)[:80])"
# Text-mode stdin must raise ParserError ("binary (rb) mode"):
cat samples/extract_report/nice-input.xml | .venv/bin/python -c \
"import sys, parsedmarc; parsedmarc.extract_report(sys.stdin)"
Gotchas
- Parse failures are WARNING-level log lines, not stderr errors — grep the
--debugoutput; the JSON just omits the report. - To compare against unfixed code:
git stash push -- <file>, run,git stash pop.