{"record":{"id":"a38a67573a5e55be","repo":"koala73/worldmonitor","slug":"seo-visibility-message","errorCode":null,"errorMessage":"[seo-visibility] ${message}","messagePattern":"\\[seo-visibility\\] (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/seo-ai-visibility-scorecard.mjs","lineNumber":116,"sourceCode":"  'dashboardLaunches',\n  'pricingViews',\n  'signUps',\n  'proConversions',\n  'activations',\n  'apiActions',\n  'mcpActions',\n]);\nexport const BING_AI_METRICS = Object.freeze([\n  'totalCitations',\n  'averageCitedPages',\n]);\n\nconst PLATFORM_LABELS = domainLabels(Object.values(AI_PLATFORM_DOMAINS).flat());\nconst PAGE_FAMILY_LABELS = domainLabels(PAGE_FAMILY_DOMAIN);\nconst INTENT_LABELS = domainLabels(INTENT_DOMAIN);\n\nfunction invariant(condition, message) {\n  if (!condition) throw new Error(`[seo-visibility] ${message}`);\n}\n\nexport function aiPlatformsForSchemaVersion(schemaVersion) {\n  invariant(\n    schemaVersion === 1 || schemaVersion === 2,\n    'baseline schemaVersion must be 1 or 2',\n  );\n  const domain = AI_PLATFORM_DOMAINS[schemaVersion];\n  return domainIds(domain);\n}\n\nexport function isNonEmptyString(value) {\n  return typeof value === 'string' && value.trim().length > 0;\n}\n\nfunction isIsoCalendarDate(value) {\n  const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value);\n  if (!match) return false;","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/koala73/worldmonitor/blob/7d06c8633d256c18e38133030bc3613976a96ec9/scripts/seo-ai-visibility-scorecard.mjs#L98-L134","documentation":"The seo-ai-visibility-scorecard script exposes an invariant() helper that throws '[seo-visibility] <message>' when an internal assumption is violated. In aiPlatformsForSchemaVersion the invariant asserts the baseline schemaVersion is 1 or 2; passing any other value aborts with this prefixed error.","triggerScenarios":"Calling aiPlatformsForSchemaVersion with a schemaVersion other than 1 or 2 — e.g. a scorecard/baseline config file with schemaVersion 3, a typo like '1 ' (string), or a config saved by a newer tool version.","commonSituations":"Hand-edited baseline JSON with a bumped schemaVersion; a colleague upgraded the tooling and saved configs with a newer schema the script does not support; type confusion passing a string instead of a number; stale configs from a renamed field.","solutions":["Set schemaVersion to 1 or 2 in the scorecard/baseline config","Regenerate the baseline config with the current version of the script","Validate the config value is an integer 1|2 before loading","If a newer schema is genuinely needed, update aiPlatformsForSchemaVersion to accept it and add migration logic"],"exampleFix":"// before\n{ \"schemaVersion\": 3 }\n// after\n{ \"schemaVersion\": 2 }","handlingStrategy":"validation","validationCode":"const ALLOWED = [1, 2];\nif (!ALLOWED.includes(config.schemaVersion)) throw new Error(`unsupported baseline schemaVersion: ${config.schemaVersion}`);","typeGuard":"const isSupportedSchemaVersion = (v) => v === 1 || v === 2;","tryCatchPattern":"try {\n  aiPlatformsForSchemaVersion(cfg.schemaVersion);\n} catch (err) {\n  if (String(err.message).startsWith('[seo-visibility]')) {\n    cfg = migrateToSupportedSchema(cfg);\n  } else throw err;\n}","preventionTips":["Pin schemaVersion in config templates to supported values","Add a JSON schema check for the baseline config at load time","Bump aiPlatformsForSchemaVersion in lockstep with schema changes"],"tags":["invariant","config","schema"],"backgroundTag":"internal-invariant-violation","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"}