{"record":{"id":"a4a2e1a862f3a74b","repo":"mastra-ai/mastra","slug":"dataset-not-found-a4a2e1","errorCode":"DATASET_NOT_FOUND","errorMessage":"Dataset not found: ${datasetId}","messagePattern":"Dataset not found: (.+?)","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/datasets/experiment/index.ts","lineNumber":260,"sourceCode":"          requestContext: dataItem.requestContext,\n          metadata: dataItem.metadata,\n          resumeSteps: dataItem.resumeSteps,\n          resumeData: dataItem.resumeData,\n          toolMocks: dataItem.toolMocks,\n          unmockedToolPolicy: dataItem.unmockedToolPolicy,\n          scorerIds: dataItem.scorerIds,\n        };\n      });\n      datasetVersion = null;\n    } else if (datasetId) {\n      // Storage-backed data path (existing)\n      if (!datasetsStore) {\n        throw new Error('DatasetsStorage not configured. Configure storage in Mastra instance.');\n      }\n\n      datasetRecord = await datasetsStore.getDatasetById({ id: datasetId, filters: config.filters });\n      if (!datasetRecord) {\n        throw new MastraError({\n          id: 'DATASET_NOT_FOUND',\n          text: `Dataset not found: ${datasetId}`,\n          domain: 'STORAGE',\n          category: 'USER',\n        });\n      }\n\n      datasetVersion = version ?? datasetRecord.version;\n      const versionItems = await datasetsStore.getItemsByVersion({\n        datasetId,\n        version: datasetVersion,\n      });\n\n      if (versionItems.length === 0) {\n        throw new MastraError({\n          id: 'EXPERIMENT_NO_ITEMS',\n          text: `No items in dataset ${datasetId} at version ${datasetVersion}`,\n          domain: 'STORAGE',","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/datasets/experiment/index.ts#L242-L278","documentation":"runExperiment looked up the dataset via datasetsStore.getDatasetById with the given ID (and optional filters) and got no record back. A MastraError with id DATASET_NOT_FOUND (domain STORAGE, category USER) is thrown so callers can match on the error code.","triggerScenarios":"Calling runExperiment with a datasetId that does not exist, was deleted, or is not visible under the supplied config.filters (e.g. scope/tenant filters exclude it).","commonSituations":"Dataset removed between creating and running the experiment; wrong environment's storage; filters (e.g. projectId/tenant) that exclude the dataset; ID copied from a different workspace.","solutions":["Check the dataset exists: await datasetsStore.getDatasetById({ id: datasetId }) and inspect the result","Remove or loosen config.filters that may be hiding the dataset","Create the dataset (or upload items) before running the experiment","Confirm the Mastra instance points at the storage environment where the dataset lives"],"exampleFix":"// before\nawait runExperiment({ datasetId: 'ds_123', ... });\n// after\nconst ds = await datasetsStore.getDatasetById({ id: 'ds_123', filters });\nif (!ds) throw new Error(`Dataset ds_123 not found — create it or fix filters first`);\nawait runExperiment({ datasetId: 'ds_123', ... });","handlingStrategy":"try-catch","validationCode":"const ds = await datasetsStore.getDatasetById({ id: datasetId, filters: config.filters });\nif (!ds) throw new Error(`Dataset ${datasetId} not found (check filters)`);","typeGuard":"function isDatasetRecord(r: unknown): r is { id: string } {\n  return !!r && typeof r === 'object' && 'id' in r;\n}","tryCatchPattern":"try {\n  await runExperiment(config);\n} catch (err) {\n  if (err instanceof MastraError && err.id === 'DATASET_NOT_FOUND') {\n    // create dataset or fix filters/ID\n  } else throw err;\n}","preventionTips":["Match on the DATASET_NOT_FOUND MastraError id rather than message text","Pre-check dataset existence with the same filters you will run with","Create datasets via a setup script before running experiments","Keep dataset IDs in per-environment config, not hardcoded"],"tags":["storage","dataset","not-found","user-input"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}