{"record":{"id":"f7267b6601628d35","repo":"koala73/worldmonitor","slug":"pagepath-brief-heading-leaks-an-iso-3166-alpha-2-code","errorCode":null,"errorMessage":"${pagePath} brief heading leaks an ISO-3166 alpha-2 code","messagePattern":"(.+?) brief heading leaks an ISO-3166 alpha-2 code","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/build-crawlable-corpus.mjs","lineNumber":3597,"sourceCode":"      .filter((match) => !/\\bclass=\"source\"/.test(match[2]))\n      .map((match) => corpusVisibleText(match[3]).replace(/&(amp|lt|gt|quot|#39);/g,\n        (entity) => ({ '&amp;': '&', '&lt;': '<', '&gt;': '>', '&quot;': '\"', '&#39;': \"'\" })[entity]));\n    const gap = briefCitationGroundingGap({ text: claims.join('\\n'), sources });\n    if (gap) throw new Error(`${pagePath} brief has unsupported citation: ${gap}`);\n  }\n  const headingSource = brief ?? main;\n  const headingHits = [...headingSource.matchAll(/<h[1-6]\\b[^>]*>([\\s\\S]*?)<\\/h[1-6]>/gi)];\n  for (const hit of headingHits) {\n    const text = hit[1].replace(/<[^>]+>/g, ' ').replace(/\\s+/g, ' ').trim();\n    if (MEANS_FOR_ISO_RE.test(text)) {\n      throw new Error(`${pagePath} heading leaks ISO code: ${text}`);\n    }\n  }\n  const briefLines = corpusMainHtml(brief ?? html)\n    .replace(/<br\\b[^>]*>|<\\/(?:p|h[1-6]|li|div)>/gi, '\\n')\n    .replace(/<[^>]+>/g, ' ');\n  if (MEANS_FOR_ISO_RE.test(briefLines)) {\n    throw new Error(`${pagePath} brief heading leaks an ISO-3166 alpha-2 code`);\n  }\n}\n\n// A floor, not completeness. #7615 shipped this as\n// `developmentsPageCount !== indexedCountryPageCount` -- every indexed country\n// owed a dated development -- which no real capture can satisfy: the news cycle\n// simply does not mention most countries. A fully keyed freeze on 2026-09-04\n// covered 61 of 196 pages (54 headline-matched, 40 briefs, 18 timelines), so\n// the gate rejected every snapshot the freeze could produce. That left the\n// weekly refresh unable to publish and armed the\n// MAX_LIVE_PULSE_SNAPSHOT_AGE_DAYS fuse against the whole corpus build.\n//\n// Rendering is not this gate's job -- assertDevelopmentsRendered already fails\n// per page when a frozen item is dropped, and it compares against the same\n// snapshot rows, so demanding equality here proved nothing extra. What is worth\n// catching is a COLLAPSE: the digest matcher breaking, or a wrong-tiered key\n// leaving briefs and timelines empty. Gate on a floor that a quiet news week\n// clears and a broken pipeline does not.","sourceCodeStart":3579,"sourceCodeEnd":3615,"githubUrl":"https://github.com/koala73/worldmonitor/blob/7d06c8633d256c18e38133030bc3613976a96ec9/scripts/build-crawlable-corpus.mjs#L3579-L3615","documentation":"Sibling of error 90: after checking headings, the corpus builder flattens the brief's block-level text (line breaks at <br>, </p>, </h*>, </li>, </div>) and runs the ISO-code regex over it. If the brief body itself carries a bare ISO-3166 alpha-2 code, the build throws rather than publishing the page.","triggerScenarios":"Running the crawlable-corpus build when the brief (or main page) prose text, after stripping tags, contains a standalone ISO-3166 alpha-2 code string matched by MEANS_FOR_ISO_RE.","commonSituations":"Brief templates that append '(US)' style code suffixes; analyst copy pasted with codes; feed data where only the alpha-2 code was available for a field the brief renders verbatim.","solutions":["Open the failing pagePath and locate the alpha-2 code occurrence in the rendered brief text.","Replace the code with the full country name in the source data or brief template.","Add a lint/template rule so brief text goes through a name-resolution helper instead of raw codes.","Rebuild and confirm the guard passes."],"exampleFix":"// before\nbrief = `Latest update for ${country.iso2}: ...`\n// after\nbrief = `Latest update for ${country.name}: ...`","handlingStrategy":"validation","validationCode":"const text = brief.replace(/<[^>]+>/g, ' ');\nif (MEANS_FOR_ISO_RE.test(text)) throw new Error('brief contains raw ISO-3166 alpha-2 code');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Route all brief prose through a name-resolution helper before render.","Ban bare alpha-2 codes in editorial style checks.","Regenerate briefs from source data instead of pasting text."],"tags":["build","seo","content-validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"7d06c8633d256c18e38133030bc3613976a96ec9","analyzedAt":"2026-09-15T16:44:39.439Z","contentChangedAt":"2026-09-15T16:44:39.439Z","schemaVersion":2},"datasetVersion":"2026-09-15T18:17:12.389Z"}