Skip to content

verify: a brand-new bill's not-yet-published PDF shouldn't fail /api/verify #124

Description

@delabrcd

Problem

/api/verify has a pdf-present check that fails when a bill has no PDF on disk. A brand-new statement registers from the API (totalDueAmount) before National Grid publishes its PDF (the PDF lags the statement by ~1–3 days). So every month, when a new bill arrives, /api/verify goes red (ok:false, "missing PDF") for a day or two until the PDF publishes — a transient false alarm that trips monitoring (Gatus) and the deploy health check, even though nothing is wrong (the scraper retries the PDF each scrape and it self-heals).

Proposal

Make the pdf-present check grace-aware: treat a bill whose statementDate is within a recent grace window (e.g. ≤ ~4 days old) and has no PDF as pending, not failed — i.e. don't count it as a verification failure. Only flag a genuinely missing PDF (an older bill whose PDF should exist but doesn't = real data loss). currentCharges-based numeric checks already skip when currentCharges is null, so this is purely the presence check.

Acceptance criteria

Pointers

  • app/src/lib/ngrid/verify.ts (the pdf-present check).
  • app/src/app/api/verify/route.ts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions