{"record":{"id":"a8f50b986bdd0226","repo":"mastra-ai/mastra","slug":"scorer-definition-with-id-id-not-found","errorCode":null,"errorMessage":"Scorer definition with id ${id} not found","messagePattern":"Scorer definition with id (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/scorer-definitions/inmemory.ts","lineNumber":97,"sourceCode":"    await this.createVersion({\n      id: versionId,\n      scorerDefinitionId: scorerDefinition.id,\n      versionNumber: 1,\n      ...snapshotConfig,\n      changedFields: Object.keys(snapshotConfig),\n      changeMessage: 'Initial version',\n    });\n\n    // Return the thin scorer record\n    return this.deepCopyScorer(newScorer);\n  }\n\n  async update(input: StorageUpdateScorerDefinitionInput): Promise<StorageScorerDefinitionType> {\n    const { id, ...updates } = input;\n\n    const existingScorer = this.db.scorerDefinitions.get(id);\n    if (!existingScorer) {\n      throw new Error(`Scorer definition with id ${id} not found`);\n    }\n\n    // Separate metadata fields from config fields\n    const { authorId, activeVersionId, metadata, status } = updates;\n\n    // Update metadata fields on the scorer record\n    const updatedScorer: StorageScorerDefinitionType = {\n      ...existingScorer,\n      ...(authorId !== undefined && { authorId }),\n      ...(activeVersionId !== undefined && { activeVersionId }),\n      ...(status !== undefined && { status: status as StorageScorerDefinitionType['status'] }),\n      ...(metadata !== undefined && {\n        metadata: { ...existingScorer.metadata, ...metadata },\n      }),\n      updatedAt: new Date(),\n    };\n\n    // Save the updated scorer record","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/scorer-definitions/inmemory.ts#L79-L115","documentation":"The in-memory scorer-definitions storage update() throws when no scorer definition with the given id exists. Updates only apply to existing records, so an unknown id is surfaced as an explicit error instead of a silent no-op.","triggerScenarios":"Calling update({ id: 's1', status: 'active' }) for an id never created, deleted, or living in a different storage instance; passing a version id or scorer id from the wrong namespace.","commonSituations":"Activating a scorer version whose definition creation step failed or was skipped; environment mismatch (dev ids used against a fresh test store); stale ids cached from a previous process.","solutions":["Create the scorer definition before updating it.","Verify the id exists via list()/get before calling update, and handle the missing branch.","Use the same storage instance for create and update (in-memory state is per-instance).","Confirm you're not confusing a scorer definition id with a version id."],"exampleFix":"// before\nawait storage.scorerDefinitions.update({ id: 'helpfulness', status: 'active' });\n// after\nconst { scorers } = await storage.scorerDefinitions.list();\nif (scorers.some(s => s.id === 'helpfulness')) {\n  await storage.scorerDefinitions.update({ id: 'helpfulness', status: 'active' });\n}","handlingStrategy":"try-catch","validationCode":"const { scorers } = await storage.scorerDefinitions.list({ perPage: false });\nif (!scorers.some(s => s.id === id)) {\n  throw new Error(`scorer definition ${id} not found; create it before updating`);\n}","typeGuard":"function scorerExists(scorers: { id: string }[], id: string): boolean {\n  return scorers.some(s => s.id === id);\n}","tryCatchPattern":"try {\n  return await storage.scorerDefinitions.update({ id, ...updates });\n} catch (e) {\n  if (e instanceof Error && e.message === `Scorer definition with id ${id} not found`) {\n    throw new Error(`Scorer ${id} missing in this storage instance; check create step and instance identity`);\n  }\n  throw e;\n}","preventionTips":["Ensure the create step completes before any update/activate step (check ordering in setup code).","Don't confuse scorer definition ids with scorer version ids.","Verify you are operating on the same in-memory storage instance that holds the definition.","Validate ids from config/env against list() output at startup."],"tags":["storage","not-found","scorer-definitions","in-memory"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}