Symptom
Shipping addresses are extracted from order emails, and a rule excludes "ships to our own address = self-purchase". The real shipping address is in another city, but our own postcode is detected inside the shipping address and the match is rejected.
Cause
The parser took a fixed 300 characters after the Shipping address header. In that mail format the Billing address block follows immediately. When the shipping address is short, 300 characters swallow the whole billing block. The billing address was our own, so the rule fired correctly on the wrong span. No error.
Fix
Cut the span at the next header, not at a length: from the start marker to the next marker (Billing address; failing that, the next blank line or section header). No fixed-length slicing.
start = body.index("Shipping address")
end = body.find("Billing address", start)
ship = body[start:end if end != -1 else start + LIMIT]
Verification
If the extracted span contains the next block's header string, the extraction failed. Billing inside a shipping address means the cut is wrong.
★ Extract a span by its end marker, not only its start. A fixed length is an unfounded claim that the next block won't fit inside it.