JuliusBrussee/caveman · error · Error

appears twice in the dataset

Error message

${at} appears twice in the dataset

What it means

Dataset case ids must be unique within the report's dataset. The validator tracks ids in a Set as it iterates dataset.cases and throws this error the moment it encounters an entry whose id was already seen, because duplicated ids would make replay results and references ambiguous.

Solutions

  1. Rename the duplicate entry's id so every dataset case id is unique.
  2. If the entries are true duplicates, delete one of them.
  3. Make the case generator namespace ids (e.g. include the perturbation or batch index) to prevent collisions.

Example fix

// before
[{ "id": "case-1", ... }, { "id": "case-1", ... }]
// after
[{ "id": "case-1", ... }, { "id": "case-1-perturbed", ... }]
Defensive patterns

Strategy: validation

Validate before calling

const seen = new Set();
for (const c of dataset.cases) {
  if (seen.has(c.id)) throw new Error(`dataset case ${c.id} duplicated`);
  seen.add(c.id);
}

Try / catch

try { validateReport(report); } catch (err) { if (String(err.message).includes('appears twice in the dataset')) { /* dedupe or rename dataset case ids */ } else throw err; }

Prevention

When it happens

Trigger: Running the validator on a report where two or more entries in dataset.cases share the same entry.id — detected when datasetCaseIDs.has(entry.id) is true on the second occurrence.

Common situations: Concatenating generated-case batches without deduplication; a generator emitting the same id for a recorded case and its perturbed variant; copy-pasting dataset entries while editing.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/26a9036018da99be. Report an issue: GitHub.

Appendix: source

Thrown at packages/shared/contracts/scripts/validate-continuous-improvement.mjs:259

    }

    // Every dataset case — recorded or generated — must name a real analysis
    // unit of this case's own task family, and its generator and perturbation
    // must agree. A generated case whose source unit cannot be resolved would be
    // invented evidence wearing an adversarial label.
    const dataset = item.eval_pack.dataset;
    const generatorPerturbation = new Map([
      ["recorded_case.v1", "none"],
      ["boundary_guard_threshold.v1", "guard_threshold_boundary"],
      ["adversarial_misleading_tool_output.v1", "misleading_tool_output"],
      ["adversarial_stale_input.v1", "stale_input"],
    ]);
    const roleCounts = { target_failure: 0, prior_success: 0, boundary: 0, adversarial: 0 };
    const recordedSources = new Set();
    const datasetCaseIDs = new Set();
    for (const entry of dataset.cases) {
      const at = `${where} dataset case ${entry.id}`;
      if (datasetCaseIDs.has(entry.id)) throw new Error(`${at} appears twice in the dataset`);
      datasetCaseIDs.add(entry.id);
      if (!unitsByID.has(entry.source_unit_id)) throw new Error(`${at} names source unit ${entry.source_unit_id} that is not an analysis unit of this report`);
      if (!familyUnits.has(entry.source_unit_id)) throw new Error(`${at} names source unit ${entry.source_unit_id} that is not a member of task family ${family.id}`);
      if (generatorPerturbation.get(entry.generator) !== entry.perturbation) {
        throw new Error(`${at} generator ${entry.generator} disagrees with perturbation ${entry.perturbation}`);
      }
      if (entry.perturbation === "none" && entry.id !== entry.source_unit_id) {
        throw new Error(`${at} replays a recorded flow but is not identified by its source unit`);
      }
      if (entry.perturbation !== "none" && entry.id !== `${entry.generator}:${entry.source_unit_id}`) {
        throw new Error(`${at} is a generated case whose id does not name its generator and source unit`);
      }
      roleCounts[entry.role] += 1;
      if (entry.role === "target_failure" || entry.role === "prior_success") recordedSources.add(entry.source_unit_id);
    }
    for (const entry of dataset.cases) {
      // Leakage: a generated case must not perturb a unit the manifest already
      // replays unperturbed.

View on GitHub (pinned to 3ee70a1026)