{"record":{"id":"4d59fd7009e68e02","repo":"mastra-ai/mastra","slug":"mastr-scorer-failed-to-run-workflow-failed","errorCode":"MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED","errorMessage":"Scorer Run Failed: ${workflowFailure.message}","messagePattern":"Scorer Run Failed: (.+?)","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/evals/base.ts","lineNumber":1075,"sourceCode":"          cause: workflowFailure,\n        });\n      }\n      throw error;\n    }\n\n    if (workflowResult.status === 'failed') {\n      const workflowFailure = getErrorFromUnknown(workflowResult.error, {\n        fallbackMessage: 'Scorer workflow failed',\n      });\n      const failedJudgeExecution = takeFailedJudgeExecution(workflowFailure);\n      const failedStepFromError = takeFailedScorerStep(workflowFailure);\n      const failureState = this.getWorkflowFailureState(workflowResult);\n      const failedStep = failedStepFromError ?? failureState.failedStep;\n      const { completedSteps, latestSuccessfulOutput } = failureState;\n      evalSpan?.error({ error: workflowFailure, endSpan: true });\n\n      if (!failedStep) {\n        throw new MastraError(\n          {\n            id: 'MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED',\n            domain: ErrorDomain.SCORER,\n            category: ErrorCategory.USER,\n            text: `Scorer Run Failed: ${workflowFailure.message}`,\n            details: {\n              scorerId: this.config.id ?? this.config.name,\n              steps: this.steps.map(s => s.name).join(', '),\n            },\n          },\n          workflowFailure,\n        );\n      }\n\n      const finalStepResult = failedJudgeExecution\n        ? this.appendFailedJudgeExecution(latestSuccessfulOutput, failedStep, failedJudgeExecution)\n        : latestSuccessfulOutput;\n      const result = this.hasScorerResultFields(finalStepResult)","sourceCodeStart":1057,"sourceCodeEnd":1093,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/evals/base.ts#L1057-L1093","documentation":"When a MastraScorer's underlying workflow run fails, run() inspects the failure state and wraps the workflow's error message in a MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED MastraError (SCORER domain, USER category), including completed steps and the failed step in details. It indicates a step inside the scorer's internal pipeline threw, rather than a config problem.","triggerScenarios":"Calling scorer.run(...) where any workflow step (preprocess, generateScore, etc.) throws — the workflow returns a failure and there is a resolvable failedStep (explicitly or from the failure state) — so the raw step error is rethrown with 'Scorer Run Failed: <message>'.","commonSituations":"A generateScore step calling an LLM that errors (bad API key, rate limits, model outage); a preprocess step throwing on unexpected input data; a custom step with a bug; network failures during score generation.","solutions":["Read the wrapped workflowFailure.message and the failedStep in error.details to find which step threw, then fix that step's root cause.","Verify LLM credentials, model availability, and rate limits if the failed step calls a model.","Harden custom steps (preprocess/generateScore) with input validation and try/catch so transient issues don't fail the whole run.","Catch this error at the call site to mark the evaluation run as failed instead of crashing the batch."],"exampleFix":"// before\nconst result = await scorer.run({ input, runId }); // crashes batch on step failure\n// after\ntry {\n  const result = await scorer.run({ input, runId });\n} catch (e) {\n  logger.error('Scorer step failed', { scorerId: 's1', cause: e.message, details: e.details });\n}","handlingStrategy":"try-catch","validationCode":"// validate inputs/credentials each step depends on before running\nif (!process.env.OPENAI_API_KEY) throw new Error('Missing OPENAI_API_KEY required by scorer steps');","typeGuard":"function isScorerWorkflowFailure(e: unknown): e is MastraError & { id: 'MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED' } {\n  return e instanceof MastraError && e.id === 'MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED';\n}","tryCatchPattern":"try {\n  const result = await scorer.run({ input, runId });\n} catch (e) {\n  if (isScorerWorkflowFailure(e)) {\n    logger.error(`Scorer step failed: ${e.details?.failedStep}`, { completedSteps: e.details?.completedSteps, cause: e.message });\n    return; // mark run failed, continue batch\n  }\n  throw e;\n}","preventionTips":["Wrap scorer.run calls in try/catch so one failing item doesn't abort an eval batch.","Inspect error.details.failedStep and completedSteps to pinpoint the failing step.","Harden step implementations (LLM retries, input validation) to reduce transient failures.","Check API keys/model availability before large scoring runs."],"tags":["scorer","workflow","evals","llm"],"backgroundTag":"scorer-workflow-step-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}