{"record":{"id":"e010ad2f60748d87","repo":"mastra-ai/mastra","slug":"mastr-scorer-failed-to-run-missing-generate-score","errorCode":"MASTR_SCORER_FAILED_TO_RUN_MISSING_GENERATE_SCORE","errorMessage":"Cannot execute pipeline without generateScore() step","messagePattern":"Cannot execute pipeline without generateScore\\(\\) step","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/evals/base.ts","lineNumber":957,"sourceCode":"    requestContext: RequestContext | undefined,\n    keys: string[] | undefined,\n  ): Record<string, unknown> | undefined {\n    if (!requestContext || !keys || keys.length === 0) {\n      return undefined;\n    }\n\n    const safe = requestContext.serializeForSpan();\n    const selected = keys.includes('*') ? safe : selectFields(safe, keys);\n\n    return Object.keys(selected).length > 0 ? selected : undefined;\n  }\n\n  async run(input: ScorerRun<TInput, TRunOutput>): Promise<ScorerRunResult<TAccumulatedResults, TInput, TRunOutput>> {\n    const { _internal, ...scorerInput } = input;\n\n    // Runtime check: execute only allowed after generateScore\n    if (!this.hasGenerateScore) {\n      throw new MastraError({\n        id: 'MASTR_SCORER_FAILED_TO_RUN_MISSING_GENERATE_SCORE',\n        domain: ErrorDomain.SCORER,\n        category: ErrorCategory.USER,\n        text: `Cannot execute pipeline without generateScore() step`,\n        details: {\n          scorerId: this.config.id ?? this.config.name,\n          steps: this.steps.map(s => s.name).join(', '),\n        },\n      });\n    }\n\n    // Apply prepareRun transformation before span creation to reduce data\n    // flowing into both the observability span and the scorer pipeline.\n    const prepared = this.config.prepareRun ? await this.config.prepareRun(scorerInput) : scorerInput;\n\n    let runId = prepared.runId;\n    if (!runId) {\n      runId = randomUUID();","sourceCodeStart":939,"sourceCodeEnd":975,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/evals/base.ts#L939-L975","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst scorer = new Scorer({ id: 's1' })\n  .preprocess(preprocessStep);\nawait scorer.run(input); // throws\n// after\nconst scorer = new Scorer({ id: 's1' })\n  .preprocess(preprocessStep)\n  .generateScore(scoreStep);\nawait scorer.run(input);","handlingStrategy":"validation","validationCode":"// check the scorer pipeline includes a generateScore step before running\nif (!scorer.hasGenerateScore) {\n  throw new Error('Scorer pipeline must include generateScore() before run()');\n}\nawait scorer.run(input);","typeGuard":null,"tryCatchPattern":"try {\n  const result = await scorer.run(input);\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'MASTR_SCORER_FAILED_TO_RUN_MISSING_GENERATE_SCORE') {\n    throw new Error(`Scorer '${e.details?.scorerId}' was built without generateScore()`);\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["scorer","pipeline","evals","missing-step"],"backgroundTag":"missing-required-pipeline-step","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}