expiry-report-missing-contracts
Weekly Expiry Reminder Report — Missing Contracts
What This Skill Diagnoses
Contracts expiring within the report window are indexed in Elasticsearch but do not appear in the report email received by the customer.
Two distinct, independently occurring root causes:
-
Missing/misconfigured
EmailConfigrouting (primary): TheCONTRACT_EXPIRATION_REPORTemail is routed per contract based onto_business_userandto_emailsfields inemails_emailconfig. A recipient only gets a contract if they are the contract's Business User (to_business_user=True) or their email is explicitly into_emailsfor that contract type's config. Contracts assigned to other BUs are silently not sent — this is WAI, not a bug. -
Elasticsearch sync lag (transient): After a bulk metadata change (e.g., deleting duplicate key pointers, running a metadata cleanup), affected contracts lose their
expiring_atindexed value temporarily. If the weekly report cron runs before re-sync completes, those contracts are absent from the ES query result. Self-heals when re-sync finishes.
Key investigative pivot: If the ES query returns the expected number of contracts but the recipient still reports missing → root cause is EmailConfig routing (cause 1). If ES query itself returns fewer contracts than expected → investigate re-sync lag (cause 2).