Skip to content

What Broke Delivery Model Alerts

Date checked: 2026-07-08.

Two issues combined.

1. Milestones Could Be Consumed Before Email Success

Introduced on 2026-03-20:

d34a7ba Wire alert emails to the main evaluation flow

The alert route wrote Delivery Model completion state back to CRM before building/sending the email. If email failed after that, the milestone was already stored in CRM and would not retry.

Fixed on 2026-06-29:

1ef2235 FIX: delivery alerts execution order preventing email alerts

That fix made failed alert candidates retryable by deferring candidate CRM writeback until email handling succeeds.

2. Production Could Not Find the Email Template

Introduced on 2026-05-16:

9f90c65 add flask app factory

Before that refactor, Flask was created from root-level server.py, so template lookup matched:

/app/templates/delivery_model_alert_email.html

After the refactor, Flask was created from package-level app/__init__.py, so default lookup moved to:

/app/app/templates

The template stayed at /app/templates/delivery_model_alert_email.html, so email rendering failed with:

delivery_model_alert_email.html

Production Evidence

The VPS cron log shows:

  • last successful candidate alert before the template-path drift: 2026-05-15 05:00 UTC;
  • first observed template failure: 2026-06-29 17:00 UTC;
  • latest checked failure: 2026-07-08 05:00 UTC, with 9 deferred milestone candidates.

Since 1ef2235, alerts have been retrying correctly, but still failing because the template cannot be found.

Fix

Keep the 1ef2235 safety behavior.

Also make Flask's template path explicit:

BASE_DIR = Path(__file__).resolve().parents[1]
app = Flask(__name__, template_folder=str(BASE_DIR / "templates"))

Add a regression test that renders the real Delivery Model alert email through create_app().