GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(aggregator/dns): isDnsSection owns finite-number + status rules (… · developing-today/code@fd1321d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • pm-stack/aggregator
    • src
      • dns.ts
    • test
      • slice3.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pm-stack/aggregator/src/dns.ts‎

Copy file name to clipboardExpand all lines: pm-stack/aggregator/src/dns.ts
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,30 @@ export function isDnsSection(v: unknown): v is DnsSection {
7777
return (
7878
typeof s.generatedAt === "string" &&
7979
Number.isFinite(Date.parse(s.generatedAt)) &&
80+
// totalAnnualListUsd is dereferenced with .toFixed on the /dns and
81+
// usage render paths, so the gate must guarantee a finite number
82+
// (#2412) — a missing/string/null/NaN total certifies a section the
83+
// renderers cannot render.
84+
typeof s.totalAnnualListUsd === "number" &&
85+
Number.isFinite(s.totalAnnualListUsd) &&
8086
Array.isArray(s.entries) &&
8187
s.entries.length > 0 &&
8288
s.entries.every(
8389
(e) =>
8490
typeof e === "object" &&
8591
e !== null &&
8692
typeof (e as DnsEntry).domain === "string" &&
87-
typeof (e as DnsEntry).renewal === "string",
93+
typeof (e as DnsEntry).renewal === "string" &&
94+
// priceUsd is number|null in the model: null/absent stays valid,
95+
// but a present value must be a finite number (#2412).
96+
((e as DnsEntry).priceUsd === null ||
97+
(e as DnsEntry).priceUsd === undefined ||
98+
(typeof (e as DnsEntry).priceUsd === "number" && Number.isFinite((e as DnsEntry).priceUsd))) &&
99+
// status feeds summarizeDns buckets; an unknown/missing status
100+
// under-counts silently, so the gate owns the enum (#2412).
101+
((e as DnsEntry).status === "active" ||
102+
(e as DnsEntry).status === "earmarked" ||
103+
(e as DnsEntry).status === "unused"),
88104
)
89105
);
90106
}
Collapse file

‎pm-stack/aggregator/test/slice3.test.ts‎

Copy file name to clipboardExpand all lines: pm-stack/aggregator/test/slice3.test.ts
+31-1Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { mkdtempSync, renameSync, rmSync, writeFileSync } from "node:fs";
44
import { tmpdir } from "node:os";
55
import { join } from "node:path";
66
import { CommentsStore, validateNewComment } from "../src/comments.ts";
7-
import { dnsSectionFromRegister, parseDnsRegister, summarizeDns } from "../src/dns.ts";
7+
import { dnsSectionFromRegister, isDnsSection, parseDnsRegister, summarizeDns } from "../src/dns.ts";
88
import type { SessionFeedEntry } from "../src/model.ts";
99
import { PAGES } from "../src/pages.ts";
1010
import { agentIdentityOf, mergeRecords, parseLaunchRecords, recordFromSessionEntry } from "../src/registry.ts";
@@ -117,6 +117,36 @@ describe("dns register parser", () => {
117117
expect(parseDnsRegister("# nothing here\n")).toEqual([]);
118118
expect(dnsSectionFromRegister("# nothing\n", "2026-10-25T00:00:00Z", "test")).toBeNull();
119119
});
120+
121+
test("isDnsSection owns the finite-number + status rules (#2412)", () => {
122+
const good = dnsSectionFromRegister(REGISTER_MD, "2026-10-25T00:00:00Z", "test");
123+
expect(good).not.toBeNull();
124+
expect(isDnsSection(good)).toBe(true);
125+
const noTotal = { ...good! } as Record<string, unknown>;
126+
delete noTotal.totalAnnualListUsd;
127+
expect(isDnsSection(noTotal)).toBe(false);
128+
expect(isDnsSection({ ...good, totalAnnualListUsd: "46.29" })).toBe(false);
129+
expect(isDnsSection({ ...good, totalAnnualListUsd: null })).toBe(false);
130+
expect(isDnsSection({ ...good, totalAnnualListUsd: Number.NaN })).toBe(false);
131+
expect(isDnsSection({ ...good, totalAnnualListUsd: Number.POSITIVE_INFINITY })).toBe(false);
132+
const withEntry = (priceUsd: unknown) => ({
133+
...good,
134+
entries: good!.entries.map((e, i) => (i === 0 ? { ...e, priceUsd } : e)),
135+
});
136+
expect(isDnsSection(withEntry("4.07"))).toBe(false);
137+
expect(isDnsSection(withEntry(Number.NaN))).toBe(false);
138+
expect(isDnsSection(withEntry(null))).toBe(true);
139+
const withStatus = (status: unknown) => ({
140+
...good,
141+
entries: good!.entries.map((e, i) => (i === 0 ? { ...e, status } : e)),
142+
});
143+
expect(isDnsSection(withStatus("bogus"))).toBe(false);
144+
expect(isDnsSection(withStatus(undefined))).toBe(false);
145+
expect(isDnsSection(withStatus("active"))).toBe(true);
146+
expect(isDnsSection(withStatus("earmarked"))).toBe(true);
147+
expect(isDnsSection(withStatus("unused"))).toBe(true);
148+
});
149+
120150
});
121151

122152
// --- Identity registry (#906 §3) ---------------------------------------------

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.