mastra-ai/mastra · error · HTTPException

Version with id ${to} not found

Error message

Version with id ${to} not found

What it means

This 404 is thrown by the scorer-versions copy-config handler when `scorerStore.getVersion(to)` returns nothing, i.e. the destination `to` version id does not exist. The handler resolves the source first, then the target, and aborts before any configuration is written.

Source

Thrown at packages/server/src/server/handlers/scorer-versions.ts:479

      if (!scorerStore) {
        throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });
      }
      const scorer = await scorerStore.getById(scorerId);
      assertStoredResourceScope(scorer, await getStoredResourceScope(mastra, requestContext));

      const fromVersion = await scorerStore.getVersion(from);
      if (!fromVersion) {
        throw new HTTPException(404, { message: `Version with id ${from} not found` });
      }
      if (fromVersion.scorerDefinitionId !== scorerId) {
        throw new HTTPException(404, {
          message: `Version with id ${from} not found for scorer ${scorerId}`,
        });
      }

      const toVersion = await scorerStore.getVersion(to);
      if (!toVersion) {
        throw new HTTPException(404, { message: `Version with id ${to} not found` });
      }
      if (toVersion.scorerDefinitionId !== scorerId) {
        throw new HTTPException(404, {
          message: `Version with id ${to} not found for scorer ${scorerId}`,
        });
      }

      const fromConfig = extractConfigFromVersion(
        fromVersion as unknown as Record<string, unknown>,
        SNAPSHOT_CONFIG_FIELDS,
      );
      const toConfig = extractConfigFromVersion(
        toVersion as unknown as Record<string, unknown>,
        SNAPSHOT_CONFIG_FIELDS,
      );

      const diffs = computeVersionDiffs(fromConfig, toConfig);

View on GitHub (pinned to 75dd419e61)

Solutions

  1. List the scorer's versions and pick an existing id for `to`.
  2. Confirm the request targets the environment whose storage holds that version.
  3. Fix typos in the `to` version id.
  4. Create the target version first, then retry the copy.

Example fix

// before
body: JSON.stringify({ from: srcId, to: 'not-created-yet' })
// after
const target = await createScorerVersion(scorerId, draftConfig);
body: JSON.stringify({ from: srcId, to: target.id })
Defensive patterns

Strategy: validation

Validate before calling

const versions = await getScorerVersions(scorerId);
if (!versions.some(v => v.id === toId)) throw new Error(`to version ${toId} does not exist for ${scorerId}`);

Try / catch

try {
  await copyScorerVersionConfig({ scorerId, from, to });
} catch (e) {
  if (e instanceof MastraClientError && e.status === 404) {
    console.error(`Target version '${to}' not found — create it or pick an existing version.`);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the copy-config endpoint with a `to` version id that is not present in scorer storage (typo, deleted version, wrong environment).

Common situations: Targeting a version that was created after your client snapshot was taken... i.e. reversed: targeting a version that was deleted; hard-coding a `to` id from a different database; passing a draft/unsaved version id.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/44d001e7efb435cf. Report an issue: GitHub.