mastra-ai/mastra · error · Error
Experiment result not found: ${input.id}
Error message
Experiment result not found: ${input.id} What it means
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.
Source
Thrown at packages/core/src/storage/domains/experiments/inmemory.ts:258
retryCount: input.retryCount,
attempt,
traceId: input.traceId ?? null,
status: input.status ?? null,
tags: input.tags ?? null,
comment: existing.comment ?? null,
toolMockReport: input.toolMockReport ?? null,
organizationId: input.organizationId ?? null,
projectId: input.projectId ?? null,
createdAt: existing.createdAt,
};
this.db.experimentResults.set(existing.id, cloneExperimentResultMetadata(replaced));
return cloneExperimentResultMetadata(replaced);
}
async updateExperimentResult(input: UpdateExperimentResultInput): Promise<ExperimentResult> {
const existing = this.db.experimentResults.get(input.id);
if (!existing) {
throw new Error(`Experiment result not found: ${input.id}`);
}
if (input.experimentId && existing.experimentId !== input.experimentId) {
throw new Error(`Experiment result ${input.id} does not belong to experiment ${input.experimentId}`);
}
const updated: ExperimentResult = {
...existing,
status: input.status !== undefined ? input.status : existing.status,
tags: input.tags !== undefined ? input.tags : existing.tags,
comment: input.comment !== undefined ? input.comment : existing.comment,
};
this.db.experimentResults.set(input.id, cloneExperimentResultMetadata(updated));
return cloneExperimentResultMetadata(updated);
}
async getExperimentResultById(args: {
id: string;
filters?: ExperimentTenancyFilters;
}): Promise<ExperimentResult | null> {View on GitHub (pinned to 75dd419e61)
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.
Example fix
// before
await storage.experiments.updateExperimentResult({ id: exp.id, status: 'success' }); // wrong id
// after
const result = await storage.experiments.createExperimentResult({ experimentId: exp.id, itemId });
await storage.experiments.updateExperimentResult({ id: result.id, status: 'success' }); Defensive patterns
Strategy: try-catch
Validate before calling
const res = await storage.experiments.getExperimentResult({ id });
if (!res) throw new Error(`Result ${id} does not exist; create it first`); Type guard
null
Try / catch
try {
await storage.experiments.updateExperimentResult({ id, status: 'success' });
} catch (e) {
if (String(e).startsWith('Experiment result not found')) {
// result creation failed earlier — create then retry, or skip
} else throw e;
} Prevention
- 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.
When it happens
Trigger: updateExperimentResult({ id, ... }) with an unknown/stale/deleted result id; undefined id when result creation failed earlier; ids from a previous in-memory session.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Experiment not found: ${input.id}
- Dataset not found: ${datasetId}
- Dataset not found: ${input.datasetId}
- Experiment result ${input.id} does not belong to experiment
- Repository link ${session.projectRepositoryId} was not found
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/115a93a65fc80eb2.
Report an issue: GitHub.