koala73/worldmonitor · error · Error

[seo-visibility] ${message}

Error message

[seo-visibility] ${message}

What it means

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.

Solutions

  1. Set schemaVersion to 1 or 2 in the scorecard/baseline config
  2. Regenerate the baseline config with the current version of the script
  3. Validate the config value is an integer 1|2 before loading
  4. If a newer schema is genuinely needed, update aiPlatformsForSchemaVersion to accept it and add migration logic

Example fix

// before
{ "schemaVersion": 3 }
// after
{ "schemaVersion": 2 }
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = [1, 2];
if (!ALLOWED.includes(config.schemaVersion)) throw new Error(`unsupported baseline schemaVersion: ${config.schemaVersion}`);

Type guard

const isSupportedSchemaVersion = (v) => v === 1 || v === 2;

Try / catch

try {
  aiPlatformsForSchemaVersion(cfg.schemaVersion);
} catch (err) {
  if (String(err.message).startsWith('[seo-visibility]')) {
    cfg = migrateToSupportedSchema(cfg);
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of koala73/worldmonitor@7d06c8633d (2026-09-15). Data as JSON: /api/errors/a38a67573a5e55be. Report an issue: GitHub.

Appendix: source

Thrown at scripts/seo-ai-visibility-scorecard.mjs:116

  'dashboardLaunches',
  'pricingViews',
  'signUps',
  'proConversions',
  'activations',
  'apiActions',
  'mcpActions',
]);
export const BING_AI_METRICS = Object.freeze([
  'totalCitations',
  'averageCitedPages',
]);

const PLATFORM_LABELS = domainLabels(Object.values(AI_PLATFORM_DOMAINS).flat());
const PAGE_FAMILY_LABELS = domainLabels(PAGE_FAMILY_DOMAIN);
const INTENT_LABELS = domainLabels(INTENT_DOMAIN);

function invariant(condition, message) {
  if (!condition) throw new Error(`[seo-visibility] ${message}`);
}

export function aiPlatformsForSchemaVersion(schemaVersion) {
  invariant(
    schemaVersion === 1 || schemaVersion === 2,
    'baseline schemaVersion must be 1 or 2',
  );
  const domain = AI_PLATFORM_DOMAINS[schemaVersion];
  return domainIds(domain);
}

export function isNonEmptyString(value) {
  return typeof value === 'string' && value.trim().length > 0;
}

function isIsoCalendarDate(value) {
  const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
  if (!match) return false;

View on GitHub (pinned to 7d06c8633d)