mastra-ai/mastra · error · HTTPException

Stored scorer definition with id ${storedScorerId} not found

Error message

Stored scorer definition with id ${storedScorerId} not found

What it means

Raised by the get-stored-scorer handler when `scorerStore.getByIdResolved(storedScorerId, { status })` returns null — no scorer definition exists for that id (optionally at the requested draft/published `status`). Returned to the client as HTTP 404.

Source

Thrown at packages/server/src/server/handlers/stored-scorers.ts:110

  tags: ['Stored Scorers'],
  requiresAuth: true,
  handler: async ({ mastra, storedScorerId, status, 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.getByIdResolved(storedScorerId, { status });

      if (!scorer) {
        throw new HTTPException(404, { message: `Stored scorer definition with id ${storedScorerId} not found` });
      }
      assertStoredResourceScope(scorer, await getStoredResourceScope(mastra, requestContext));

      return scorer;
    } catch (error) {
      return handleError(error, 'Error getting stored scorer definition');
    }
  },
});

/**
 * POST /stored/scorers - Create a new stored scorer definition
 */
export const CREATE_STORED_SCORER_ROUTE = createRoute({
  method: 'POST',
  path: '/stored/scorers',
  responseType: 'json',
  bodySchema: createStoredScorerBodySchema,

View on GitHub (pinned to 75dd419e61)

Solutions

  1. List stored scorers to confirm the exact id and drop the `status` query param (or use `draft`) if the scorer is unpublished.
  2. Publish the scorer definition if you specifically need the published version.
  3. Confirm the server points at the storage environment where the scorer was created.
  4. Handle 404 client-side by showing 'scorer not found' instead of retrying.

Example fix

// before
getScorer('my-scorer', { status: 'published' }); // 404: only a draft exists

// after
getScorer('my-scorer'); // or publish it first
Defensive patterns

Strategy: try-catch

Validate before calling

const all = await listStoredScorers();
if (!all.results.some(s => s.id === id)) console.warn(`Scorer ${id} not present; statuses available:`, all.results.map(s => ({ id: s.id })));

Type guard

function scorerExists(list: { id: string }[], id: string) { return list.find(s => s.id === id); }

Try / catch

try {
  return await getStoredScorer(id, { status: 'published' });
} catch (e) {
  if (e.status === 404) return null; // render 'not found' UI
  throw e;
}

Prevention

When it happens

Trigger: GET stored scorer with an id never registered; requesting `status=published` for a scorer that only exists as a draft; id from a different database/environment; typo'd slug.

Common situations: Frontend linking to a scorer that was deleted; querying the published variant before the scorer was ever published; CI tests using fixture ids against an empty database.

Related errors


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