{"record":{"id":"115a93a65fc80eb2","repo":"mastra-ai/mastra","slug":"experiment-result-not-found-input-id","errorCode":null,"errorMessage":"Experiment result not found: ${input.id}","messagePattern":"Experiment result not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/experiments/inmemory.ts","lineNumber":258,"sourceCode":"      retryCount: input.retryCount,\n      attempt,\n      traceId: input.traceId ?? null,\n      status: input.status ?? null,\n      tags: input.tags ?? null,\n      comment: existing.comment ?? null,\n      toolMockReport: input.toolMockReport ?? null,\n      organizationId: input.organizationId ?? null,\n      projectId: input.projectId ?? null,\n      createdAt: existing.createdAt,\n    };\n    this.db.experimentResults.set(existing.id, cloneExperimentResultMetadata(replaced));\n    return cloneExperimentResultMetadata(replaced);\n  }\n\n  async updateExperimentResult(input: UpdateExperimentResultInput): Promise<ExperimentResult> {\n    const existing = this.db.experimentResults.get(input.id);\n    if (!existing) {\n      throw new Error(`Experiment result not found: ${input.id}`);\n    }\n    if (input.experimentId && existing.experimentId !== input.experimentId) {\n      throw new Error(`Experiment result ${input.id} does not belong to experiment ${input.experimentId}`);\n    }\n    const updated: ExperimentResult = {\n      ...existing,\n      status: input.status !== undefined ? input.status : existing.status,\n      tags: input.tags !== undefined ? input.tags : existing.tags,\n      comment: input.comment !== undefined ? input.comment : existing.comment,\n    };\n    this.db.experimentResults.set(input.id, cloneExperimentResultMetadata(updated));\n    return cloneExperimentResultMetadata(updated);\n  }\n\n  async getExperimentResultById(args: {\n    id: string;\n    filters?: ExperimentTenancyFilters;\n  }): Promise<ExperimentResult | null> {","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/experiments/inmemory.ts#L240-L276","documentation":"updateExperimentResult throws when input.id does not resolve in the experimentResults map. Results must exist (created during experiment runs) before they can be updated; no upsert is performed.","triggerScenarios":"updateExperimentResult({ id, ... }) with an unknown/stale/deleted result id; undefined id when result creation failed earlier; ids from a previous in-memory session.","commonSituations":"Streaming run results into a result record that failed to create; resuming after process restart; using the experiment id instead of the result id by mistake.","solutions":["Verify you are passing the result id, not the experiment id.","Ensure the result was created (createExperimentResult / experiment run) and capture its returned id.","Check the store wasn't restarted — in-memory results are lost between sessions.","Handle creation failure upstream so you never update a nonexistent result."],"exampleFix":"// before\nawait storage.experiments.updateExperimentResult({ id: exp.id, status: 'success' }); // wrong id\n// after\nconst result = await storage.experiments.createExperimentResult({ experimentId: exp.id, itemId });\nawait storage.experiments.updateExperimentResult({ id: result.id, status: 'success' });","handlingStrategy":"try-catch","validationCode":"const res = await storage.experiments.getExperimentResult({ id });\nif (!res) throw new Error(`Result ${id} does not exist; create it first`);","typeGuard":"null","tryCatchPattern":"try {\n  await storage.experiments.updateExperimentResult({ id, status: 'success' });\n} catch (e) {\n  if (String(e).startsWith('Experiment result not found')) {\n    // result creation failed earlier — create then retry, or skip\n  } else throw e;\n}","preventionTips":["Capture result ids from the creation call; never guess or reuse experiment ids.","Check creation errors so updates never target nonexistent results.","Recreate results after any store restart."],"tags":["storage","experiments","inmemory","missing-resource"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}