mastra-ai/mastra · error · MastraError

SCORES_STORAGE_GET_SCORES_BY_SPAN_NOT_IMPLEMENTED

SCORES_STORAGE_GET_SCORES_BY_SPAN_NOT_IMPLEMENTED

Error message

SCORES_STORAGE_GET_SCORES_BY_SPAN_NOT_IMPLEMENTED

What it means

listScoresBySpan has no default implementation on the abstract MastraStorage scores domain: the base class deliberately throws a MastraError with id SCORES_STORAGE_GET_SCORES_BY_SPAN_NOT_IMPLEMENTED. Hitting this means the storage adapter in use does not support querying scores by trace/span pair.

Source

Thrown at packages/core/src/storage/domains/scores/base.ts:37

    });
  }

  async dangerouslyClearAll(): Promise<void> {
    // Default no-op - subclasses override
  }

  abstract getScoreById({ id }: { id: string }): Promise<ScoreRowData | null>;

  abstract saveScore(score: SaveScorePayload): Promise<{ score: ScoreRowData }>;

  abstract listScoresByScorerId(input: ListScoresByScorerIdInput): Promise<ListScoresResponse>;

  abstract listScoresByRunId(input: ListScoresByRunIdInput): Promise<ListScoresResponse>;

  abstract listScoresByEntityId(input: ListScoresByEntityIdInput): Promise<ListScoresResponse>;

  async listScoresBySpan({ traceId, spanId }: ListScoresBySpanInput): Promise<ListScoresResponse> {
    throw new MastraError({
      id: 'SCORES_STORAGE_GET_SCORES_BY_SPAN_NOT_IMPLEMENTED',
      domain: ErrorDomain.STORAGE,
      category: ErrorCategory.SYSTEM,
      details: { traceId, spanId },
    });
  }
}

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Upgrade or switch to a storage adapter that implements listScoresBySpan.
  2. Use listScoresByEntityId or listScoresByRunId instead and filter results client-side by traceId/spanId if supported.
  3. Implement listScoresBySpan in your custom storage subclass.
  4. Add a feature check / try-catch around the call and degrade gracefully.

Example fix

// before
const scores = await storage.listScoresBySpan({ traceId, spanId }); // throws
// after
const { scores: all } = await storage.listScoresByEntityId({ entityId: 'agent-1' });
const spanScores = all.filter(s => s.traceId === traceId && s.spanId === spanId);
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

function supportsListScoresBySpan(s: unknown): s is { listScoresBySpan: Function } {
  return typeof (s as any)?.listScoresBySpan === 'function' &&
    !s.constructor?.name?.includes('Base');
}

Try / catch

try {
  return await storage.listScoresBySpan({ traceId, spanId });
} catch (e) {
  if (e instanceof MastraError && e.id === 'SCORES_STORAGE_GET_SCORES_BY_SPAN_NOT_IMPLEMENTED') {
    logger.warn('listScoresBySpan unsupported by adapter; falling back');
    return await storage.listScoresByEntityId({ entityId }).then(r => filterBySpan(r, traceId, spanId));
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling storage.listScoresBySpan({ traceId, spanId }) on an adapter that has not overridden the method (e.g. a minimal or custom storage class, or an older adapter version lacking span-level score queries).

Common situations: Switching storage backends (e.g. to LibSQL/Upstash/custom) whose implementation doesn't implement this optional method; calling a newer API surface against an older adapter; custom storage subclasses that only implement the abstract methods.

Related errors


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