mastra-ai/mastra · error · HTTPException

Scorer with id ${scorerId} not found

Error message

Scorer with id ${scorerId} not found

What it means

Thrown as HTTP 404 when scorerStore.getById(scorerId) finds no scorer definition matching the given id. The library raises it after storage is confirmed working, meaning the identifier itself is wrong or the record does not exist in this deployment's storage.

Source

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

  summary: 'List scorer versions',
  description: 'Returns a paginated list of all versions for a stored scorer',
  tags: ['Scorer Versions'],
  handler: async ({ mastra, scorerId, page, perPage, orderBy, requestContext }) => {
    try {
      const storage = mastra.getStorage();

      if (!storage) {
        throw new HTTPException(500, { message: 'Storage is not configured' });
      }

      const scorerStore = await storage.getStore('scorerDefinitions');
      if (!scorerStore) {
        throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });
      }

      const scorer = await scorerStore.getById(scorerId);
      if (!scorer) {
        throw new HTTPException(404, { message: `Scorer with id ${scorerId} not found` });
      }
      assertStoredResourceScope(scorer, await getStoredResourceScope(mastra, requestContext));

      const result = await scorerStore.listVersions({
        scorerDefinitionId: scorerId,
        page,
        perPage,
        orderBy,
      });

      return result;
    } catch (error) {
      return handleError(error, 'Error listing scorer versions');
    }
  },
});

/**

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Verify the scorerId by listing scorers (GET /api/scorers) and using an id from the response
  2. Confirm the server is pointed at the database/environment where the scorer actually exists
  3. Re-register or recreate the scorer if it was deleted
  4. Fix the id typo in the calling client/config

Example fix

// before
await fetch(`/api/scorers/scorer_prod_v1/versions`);
// after — resolve the real id first
const scorers = await (await fetch('/api/scorers')).json();
const id = scorers.find(s => s.name === 'my-scorer').id;
await fetch(`/api/scorers/${id}/versions`);
Defensive patterns

Strategy: try-catch

Validate before calling

const scorers = await (await fetch('/api/scorers')).json();
const exists = scorers.some(s => s.id === scorerId);
if (!exists) throw new Error(`Unknown scorerId: ${scorerId}`);

Type guard

function isKnownScorer(scorerId: string, known: { id: string }[]): boolean {
  return known.some(s => s.id === scorerId);
}

Try / catch

const res = await fetch(`/api/scorers/${scorerId}/versions`);
if (res.status === 404) {
  // resolve correct scorerId via list endpoint before retrying
}

Prevention

When it happens

Trigger: GET /api/scorers/{scorerId}/versions with a scorerId that is not present in the scorer_definitions table — typo'd id, id from another environment/database, or the scorer was deleted.

Common situations: Hardcoding a scorer id copied from local dev into staging; referencing a scorer that exists only in code (registered in Mastra) but was never persisted/registered in the version store; after truncating/migrating the database.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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