diff --git a/pm-stack/aggregator/src/dns.ts b/pm-stack/aggregator/src/dns.ts index a678ab4293..589c65512f 100644 --- a/pm-stack/aggregator/src/dns.ts +++ b/pm-stack/aggregator/src/dns.ts @@ -48,7 +48,12 @@ export function parseDnsRegister(md: string): DnsEntry[] { const cells = line.split("|").slice(1, -1).map(cleanCell); if (cells.length < 10) continue; const [domain, registrar, dnsHost, renewal, autoRenew, price, priorYearCost, used, plan, review] = cells; - if (!domain || !/^\d{4}-\d{2}-\d{2}$/.test(renewal)) continue; + // Shape alone is not enough: an impossible calendar date (2026-02-30, + // 2026-13-01) must be refused like a malformed row, or it string-sorts + // into the register, counts toward the annual total, and poisons + // nextRenewal / renewingSoon (#2199). isIsoDate re-checks the + // components, so leap dates (2024-02-29) still parse. + if (!domain || !/^\d{4}-\d{2}-\d{2}$/.test(renewal) || !isIsoDate(renewal)) continue; out.push({ domain, registrar, diff --git a/pm-stack/aggregator/test/slice3.test.ts b/pm-stack/aggregator/test/slice3.test.ts index f7f9fc0986..24e3504ab9 100644 --- a/pm-stack/aggregator/test/slice3.test.ts +++ b/pm-stack/aggregator/test/slice3.test.ts @@ -44,6 +44,25 @@ describe("dns register parser", () => { expect(entries.find((e) => e.domain === "noprice.example")?.priceUsd).toBeNull(); }); + test("rejects impossible calendar renewal dates, keeps the leap date (#2199)", () => { + const md = [ + "# DNS / Domain Register", + "", + "| Domain | Registrar | DNS hosted at | Next renewal | Auto-renew | Renewal price (list) | Prior-year cost | Where used | Plan / status | Review? |", + "|---|---|---|---|---|---|---|---|---|---|", + "| feb30.example | Porkbun | Porkbun | 2026-02-30 | ON | $20.00 | unknown | Parked | Parked | REVIEW |", + "| month13.example | Porkbun | Porkbun | 2026-13-01 | ON | $30.00 | unknown | Parked | Parked | REVIEW |", + "| month00.example | Porkbun | Porkbun | 2026-00-10 | ON | $40.00 | unknown | Parked | Parked | REVIEW |", + "| apr31.example | Porkbun | Porkbun | 2026-04-31 | ON | $50.00 | unknown | Parked | Parked | REVIEW |", + "| leap.example | Porkbun | Porkbun | 2024-02-29 | ON | $5.00 | unknown | Parked | Parked | REVIEW |", + "| real.example | Porkbun | Porkbun | 2027-01-15 | ON | $10.00 | unknown | Parked | Parked | REVIEW |", + ].join("\n"); + const entries = parseDnsRegister(md); + expect(entries.map((e) => e.domain)).toEqual(["leap.example", "real.example"]); + const section = dnsSectionFromRegister(md, "2026-10-25T00:00:00Z", "test"); + expect(section?.totalAnnualListUsd).toBe(15); + }); + test("classifies active / earmarked / unused from the plan cell", () => { const entries = parseDnsRegister(REGISTER_MD); const byStatus = (s: string) => entries.filter((e) => e.status === s).map((e) => e.domain);