koala73/worldmonitor · error

writeAccuracySection requires the canonical DataCatalog iden

Error message

writeAccuracySection requires the canonical DataCatalog identity so the scorecard Dataset joins the catalog graph

What it means

writeAccuracySection builds the /accuracy/ page and its JSON-LD structured data. It requires both the DataCatalog node and the dataset's catalog reference to carry canonical '@id' values so the scorecard Dataset entity links into the catalog's knowledge graph. When either identity is missing the function throws instead of emitting broken/invalid structured data.

Solutions

  1. Ensure the dataCatalog object passed in includes a canonical '@id' URL.
  2. Ensure each dataset has dataset.catalog['@id'] pointing at the catalog's canonical identity.
  3. Check where datasets are constructed/loaded and add the catalog linkage for any newly added dataset.
  4. Add a pre-flight check on the dataset config so missing identities fail with a clearer message.

Example fix

// before
writeAccuracySection({ dataset: { name: 'conflicts' }, snapshotPath });
// after
writeAccuracySection({
  dataset: { name: 'conflicts', catalog: { '@id': 'https://worldmonitor.app/#datacatalog' } },
  dataCatalog: { '@id': 'https://worldmonitor.app/#datacatalog' },
  snapshotPath,
});
Defensive patterns

Strategy: validation

Validate before calling

for (const d of datasets) {
  if (!dataCatalog?.['@id']) throw new Error('dataCatalog missing @id');
  if (!d.catalog?.['@id']) throw new Error(`dataset ${d.name} missing catalog @id`);
}

Type guard

const hasCatalogIdentity = (d) => typeof d?.catalog?.['@id'] === 'string' && d.catalog['@id'].length > 0;

Try / catch

try {
  writeAccuracySection({ dataset, dataCatalog, snapshotPath });
} catch (e) {
  if (String(e.message).includes('canonical DataCatalog identity')) {
    console.error('Wire dataset/catalog @id before building /accuracy/:', e.message);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling writeAccuracySection (or the build script) with dataCatalog undefined/null or without '@id', or with dataset.catalog missing its '@id' field.

Common situations: Adding a new dataset entry without wiring it into the DataCatalog registry; refactoring the JSON-LD builders and dropping the '@id' field; passing a partial catalog object in a test harness.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at scripts/build-accuracy-page.mjs:732

    confidenceIntervals: { published: false, trackedIn: CONFIDENCE_INTERVAL_ISSUE },
    horizonProjections: { scored: false, trackedIn: HORIZON_SCORING_ISSUE },
    scorecard: state.scorecard,
  };
  return `${JSON.stringify(payload, null, 2)}\n`;
}

export function writeAccuracySection({
  outDir,
  baseUrl,
  tpl,
  section,
  lastmod = ACCURACY_CONTENT_VERSION,
  dataset,
  dataCatalog,
  snapshotPath,
}) {
  if (!dataCatalog?.['@id'] || !dataset?.catalog?.['@id']) {
    throw new Error(
      'writeAccuracySection requires the canonical DataCatalog identity so the scorecard Dataset joins the catalog graph',
    );
  }
  const state = classifyAccuracyState(section);
  mkdirSync(join(outDir, 'accuracy'), { recursive: true });
  writeFileSync(
    join(outDir, 'accuracy', 'index.html'),
    renderAccuracyPage({ baseUrl, tpl, state, lastmod, dataset, dataCatalog, snapshotPath }),
  );
  const downloadPath = join(outDir, dataset.file);
  mkdirSync(dirname(downloadPath), { recursive: true });
  writeFileSync(downloadPath, accuracyDatasetDownload({ state, snapshotPath }));
  return { state };
}

View on GitHub (pinned to 7d06c8633d)