{"record":{"id":"809aea47f68ed06a","repo":"mastra-ai/mastra","slug":"experiment-not-found-input-id","errorCode":null,"errorMessage":"Experiment not found: ${input.id}","messagePattern":"Experiment not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/experiments/inmemory.ts","lineNumber":79,"sourceCode":"      totalItems: input.totalItems,\n      succeededCount: 0,\n      failedCount: 0,\n      skippedCount: 0,\n      organizationId: input.organizationId ?? null,\n      projectId: input.projectId ?? null,\n      startedAt: null,\n      completedAt: null,\n      createdAt: now,\n      updatedAt: now,\n    };\n    this.db.experiments.set(experiment.id, structuredClone(experiment));\n    return structuredClone(experiment);\n  }\n\n  async updateExperiment(input: UpdateExperimentInput): Promise<Experiment> {\n    const existing = this.db.experiments.get(input.id);\n    if (!existing) {\n      throw new Error(`Experiment not found: ${input.id}`);\n    }\n    const updated: Experiment = {\n      ...existing,\n      status: input.status ?? existing.status,\n      totalItems: input.totalItems ?? existing.totalItems,\n      succeededCount: input.succeededCount ?? existing.succeededCount,\n      failedCount: input.failedCount ?? existing.failedCount,\n      skippedCount: input.skippedCount ?? existing.skippedCount,\n      startedAt: input.startedAt ?? existing.startedAt,\n      completedAt: input.completedAt ?? existing.completedAt,\n      name: input.name ?? existing.name,\n      description: input.description ?? existing.description,\n      metadata: input.metadata ?? existing.metadata,\n      updatedAt: new Date(),\n    };\n    this.db.experiments.set(input.id, structuredClone(updated));\n    return structuredClone(updated);\n  }","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/experiments/inmemory.ts#L61-L97","documentation":"updateExperiment requires an existing experiment row; when input.id does not resolve in the in-memory experiments map it throws a plain Error. The store does not upsert — the experiment must have been created first.","triggerScenarios":"updateExperiment({ id, status/totalItems/... }) with an id that was never created, already deleted, or from a restarted store; typo'd or undefined experiment id.","commonSituations":"Experiment worker resuming after dev-server restart (in-memory data lost); two storage instances (e.g., different module imports) with divergent maps; reporting progress for an experiment whose creation failed.","solutions":["Confirm the id came from createExperiment's return value and was not recreated since.","Check the experiment still exists (listExperiment/get) before updating.","Re-create the experiment if the store was restarted; in-memory storage is not durable.","Ensure a single shared storage instance is injected everywhere (avoid duplicate module instantiation)."],"exampleFix":"// before\nawait storage.experiments.updateExperiment({ id: expId, status: 'running' });\n// after\nconst exp = await storage.experiments.getExperiment({ id: expId });\nif (!exp) throw new Error(`Experiment ${expId} vanished — recreate before updating`);\nawait storage.experiments.updateExperiment({ id: expId, status: 'running' });","handlingStrategy":"try-catch","validationCode":"const exp = await storage.experiments.getExperiment({ id });\nif (!exp) throw new Error(`Cannot update missing experiment ${id}`);","typeGuard":"null","tryCatchPattern":"try {\n  await storage.experiments.updateExperiment({ id, status: 'completed' });\n} catch (e) {\n  if (String(e).startsWith('Experiment not found')) {\n    // store restarted or id stale: recreate or surface to caller\n  } else throw e;\n}","preventionTips":["Only update experiments created in the same storage instance/session.","Persist experiment ids outside the store if you must survive restarts — or use durable storage.","Verify creation succeeded before starting progress updates."],"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"}