expiry-report-missing-contracts

Installation
SKILL.md

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:

  1. Missing/misconfigured EmailConfig routing (primary): The CONTRACT_EXPIRATION_REPORT email is routed per contract based on to_business_user and to_emails fields in emails_emailconfig. A recipient only gets a contract if they are the contract's Business User (to_business_user=True) or their email is explicitly in to_emails for that contract type's config. Contracts assigned to other BUs are silently not sent — this is WAI, not a bug.

  2. Elasticsearch sync lag (transient): After a bulk metadata change (e.g., deleting duplicate key pointers, running a metadata cleanup), affected contracts lose their expiring_at indexed 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).

Investigation Workflow

Step 1 — Confirm ES query returns expected contracts

Installs
1
First Seen
Apr 9, 2026