{"record":{"id":"14bcdad3db995da3","repo":"mastra-ai/mastra","slug":"mastra-scorer-not-found","errorCode":"MASTRA_SCORER_NOT_FOUND","errorMessage":"Scorer with ID ${scorerId} not found","messagePattern":"Scorer with ID (.+?) not found","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/mastra/hooks.ts","lineNumber":48,"sourceCode":"      mastra.getLogger()?.warn('Storage not found, skipping score validation and saving');\n      return;\n    }\n\n    const entityId = hookData.entity.id as string;\n    const entityType = hookData.entityType;\n    const scorer = hookData.scorer;\n    const scorerId = scorer.id as string;\n\n    if (!scorerId) {\n      mastra.getLogger()?.warn('Scorer ID not found, skipping score validation and saving');\n      return;\n    }\n\n    try {\n      const scorerToUse = await findScorer(mastra, entityId, entityType, scorerId);\n\n      if (!scorerToUse) {\n        throw new MastraError({\n          id: 'MASTRA_SCORER_NOT_FOUND',\n          domain: ErrorDomain.MASTRA,\n          category: ErrorCategory.USER,\n          text: `Scorer with ID ${scorerId} not found`,\n        });\n      }\n\n      let input = hookData.input;\n      let output = hookData.output;\n\n      const { structuredOutput, ...rest } = hookData;\n\n      const currentSpan = hookData.tracingContext?.currentSpan;\n      const traceId = currentSpan?.isValid ? currentSpan.traceId : undefined;\n      const spanId = currentSpan?.isValid ? currentSpan.id : undefined;\n      const targetCorrelationContext = currentSpan?.isValid ? currentSpan.getCorrelationContext?.() : undefined;\n      const targetMetadata = currentSpan?.isValid && currentSpan.metadata ? { ...currentSpan.metadata } : undefined;\n      const runResult = await scorerToUse.scorer.run({","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/mastra/hooks.ts#L30-L66","documentation":"The onScorer hook resolves the scorer by id through findScorer(mastra, entityId, entityType, scorerId); if no scorer with that ID is registered (locally or via storage), it throws this USER-category MastraError. It means the scoring hook was invoked for a scorer that the Mastra instance does not know about.","triggerScenarios":"Calling mastra.getScorer()/the onScorer hook with a scorerId string that was never registered with mastra.registerScorer(), a typo'd id, or a scorer registered on a different Mastra instance than the one executing the agent run.","commonSituations":"Copy-pasting a scorer id from docs/examples without registering it; registering scorers after the agent run already started; renaming a scorer and not updating references; running scorers in a service with its own Mastra instance that lacks the registration.","solutions":["Register the scorer before the run: mastra.registerScorer({ scorer, name: '...' }) and use the registered id.","Verify the exact id string matches the registered scorer name/id (watch casing/typos).","Ensure the same Mastra instance that runs the agent is the one with the scorer registered.","Check entity type (agent/workflow) registration path — findScorer looks up per entityId/entityType, so confirm the scorer is attached to the right entity.","Import the scorer registration in the entrypoint so it actually executes before the hook runs."],"exampleFix":"// before\nconst result = await agent.generate('hi', { scorers: [{ scorerId: 'answer-relevance' }] }); // never registered\n// after\nmastra.registerScorer({ scorer: new AnswerRelevanceScorer(), name: 'answer-relevance' });\nconst result = await agent.generate('hi', { scorers: [{ scorerId: 'answer-relevance' }] });","handlingStrategy":"validation","validationCode":"const registered = mastra.getScorers?.() ?? [];\nif (!registered.some(s => (s.name ?? s.id) === scorerId)) {\n  throw new Error(`Scorer ${scorerId} must be registered via mastra.registerScorer() before use`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runWithScorers();\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'MASTRA_SCORER_NOT_FOUND') {\n    console.error(`Scorer ${scorerId} not registered on this Mastra instance`);\n  }\n  throw e;\n}","preventionTips":["Register scorers at bootstrap, before any agent runs","Reference scorer ids from a single constants module to avoid typos","Verify the scorer is attached to the correct entityId/entityType"],"tags":["scorers","registration","configuration"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}