mastra-ai/mastra · error · MastraError
MASTR_SCORER_FAILED_TO_RUN_MISSING_GENERATE_SCORE
MASTR_SCORER_FAILED_TO_RUN_MISSING_GENERATE_SCORE
Error message
Cannot execute pipeline without generateScore() step
What it means
MastraScorer builds a pipeline of steps and only permits execute/run after a generateScore step has been added, since the scorer cannot produce results without it. run() performs a runtime check on hasGenerateScore and throws MASTR_SCORER_FAILED_TO_RUN_MISSING_GENERATE_SCORE when the pipeline lacks that step.
Source
Thrown at packages/core/src/evals/base.ts:957
requestContext: RequestContext | undefined,
keys: string[] | undefined,
): Record<string, unknown> | undefined {
if (!requestContext || !keys || keys.length === 0) {
return undefined;
}
const safe = requestContext.serializeForSpan();
const selected = keys.includes('*') ? safe : selectFields(safe, keys);
return Object.keys(selected).length > 0 ? selected : undefined;
}
async run(input: ScorerRun<TInput, TRunOutput>): Promise<ScorerRunResult<TAccumulatedResults, TInput, TRunOutput>> {
const { _internal, ...scorerInput } = input;
// Runtime check: execute only allowed after generateScore
if (!this.hasGenerateScore) {
throw new MastraError({
id: 'MASTR_SCORER_FAILED_TO_RUN_MISSING_GENERATE_SCORE',
domain: ErrorDomain.SCORER,
category: ErrorCategory.USER,
text: `Cannot execute pipeline without generateScore() step`,
details: {
scorerId: this.config.id ?? this.config.name,
steps: this.steps.map(s => s.name).join(', '),
},
});
}
// Apply prepareRun transformation before span creation to reduce data
// flowing into both the observability span and the scorer pipeline.
const prepared = this.config.prepareRun ? await this.config.prepareRun(scorerInput) : scorerInput;
let runId = prepared.runId;
if (!runId) {
runId = randomUUID();View on GitHub (pinned to 75dd419e61)
Solutions
- Add a .generateScore(...) step to the scorer's pipeline before running it.
- If steps are chained conditionally, make generateScore mandatory/unconditional in the chain.
- Check that you are calling run/execute on the fully built scorer, not a partial builder result that skipped the scoring step.
Example fix
// before
const scorer = new Scorer({ id: 's1' })
.preprocess(preprocessStep);
await scorer.run(input); // throws
// after
const scorer = new Scorer({ id: 's1' })
.preprocess(preprocessStep)
.generateScore(scoreStep);
await scorer.run(input); Defensive patterns
Strategy: validation
Validate before calling
// check the scorer pipeline includes a generateScore step before running
if (!scorer.hasGenerateScore) {
throw new Error('Scorer pipeline must include generateScore() before run()');
}
await scorer.run(input); Try / catch
try {
const result = await scorer.run(input);
} catch (e) {
if (e instanceof MastraError && e.id === 'MASTR_SCORER_FAILED_TO_RUN_MISSING_GENERATE_SCORE') {
throw new Error(`Scorer '${e.details?.scorerId}' was built without generateScore()`);
}
throw e;
} Prevention
- Always terminate scorer builder chains with .generateScore(...).
- Make generateScore unconditional when steps are added programmatically.
- If type-safe builder variants exist (scorers without generateScore lacking run), use them so the mistake is a compile error.
When it happens
Trigger: Calling scorer.run(...) (or execute) on a scorer whose builder chain never invoked .generateScore(...) — e.g. only preprocess/other steps were added — then attempting to execute the scorer pipeline.
Common situations: Composing a scorer from steps and forgetting the scoring step; conditionally chaining steps with the generateScore branch omitted; refactoring a scorer and accidentally dropping the generateScore() call.
Related errors
- MASTR_SCORER_FAILED_TO_CREATE_MISSING_ID
- MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED
- RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_RESULT
- RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_TRAJECTORY
- RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_STEP_RESULT
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/e010ad2f60748d87.
Report an issue: GitHub.