{"record":{"id":"92f2d7fcff2645bf","repo":"mastra-ai/mastra","slug":"no-data-source-provide-datasetid-or-data","errorCode":null,"errorMessage":"No data source: provide datasetId or data","messagePattern":"No data source: provide datasetId or data","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/datasets/experiment/index.ts","lineNumber":296,"sourceCode":"          domain: 'STORAGE',\n          category: 'USER',\n        });\n      }\n\n      items = versionItems.map(v => ({\n        id: v.id,\n        datasetVersion: v.datasetVersion,\n        input: v.input,\n        groundTruth: v.groundTruth,\n        expectedTrajectory: v.expectedTrajectory as TrajectoryExpectation | undefined,\n        requestContext: v.requestContext,\n        metadata: v.metadata,\n        toolMocks: v.toolMocks,\n        unmockedToolPolicy: v.unmockedToolPolicy,\n        scorerIds: v.scorerIds,\n      }));\n    } else {\n      throw new Error('No data source: provide datasetId or data');\n    }\n  } catch (err) {\n    await markFailedOnSetupError(err);\n    throw err; // unreachable, but satisfies TS control flow\n  }\n\n  // Phase B — Resolve task function\n  let execFn: (item: ExperimentItem, signal?: AbortSignal) => Promise<ExecutionResult>;\n\n  try {\n    if (config.task) {\n      // Inline task path\n      const taskFn = config.task;\n      execFn = async (item, itemSignal) => {\n        try {\n          const result = await taskFn({\n            input: item.input,\n            mastra,","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/datasets/experiment/index.ts#L278-L314","documentation":"runExperiment requires exactly one data source: either a storage-backed datasetId or inline `data`. When neither is supplied, this plain Error is thrown from the data-source resolution branch, and the run is marked failed during setup before any items execute.","triggerScenarios":"Calling runExperiment (or startExperiment/startExperimentAsync/executeRun) with a config that omits both datasetId and data.","commonSituations":"Building config programmatically where the data field ends up undefined (failed fetch assigned to data); spreading a partial options object; forgetting to pass data after removing a datasetId.","solutions":["Pass inline `data: [...]` items to runExperiment","Or pass a `datasetId` pointing at a stored dataset","Validate the config object before calling (ensure data or datasetId is a non-empty value)","Fix the upstream code that was supposed to populate `data` (e.g. check the fetch/loading result)"],"exampleFix":"// before\nconst data = await loadData(); // may return undefined\nawait runExperiment({ ...config, data });\n// after\nconst data = await loadData();\nif (!data || data.length === 0) throw new Error('loadData returned no data');\nawait runExperiment({ ...config, data });","handlingStrategy":"validation","validationCode":"if (!config.datasetId && !(Array.isArray(config.data) && config.data.length > 0)) {\n  throw new Error('runExperiment requires datasetId or non-empty data');\n}","typeGuard":"function hasDataSource(c: { datasetId?: string; data?: unknown[] }): boolean {\n  return typeof c.datasetId === 'string' || (Array.isArray(c.data) && c.data.length > 0);\n}","tryCatchPattern":"try {\n  await runExperiment(config);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('No data source')) {\n    console.error('Experiment config missing both datasetId and data');\n  } else throw err;\n}","preventionTips":["Validate experiment configs with a zod schema enforcing data XOR datasetId","Avoid assigning possibly-undefined results to the data field","Log the assembled config before running in CI pipelines","Provide defaults for data loading with explicit failure when empty"],"tags":["configuration","experiment","invalid-argument","user-input"],"backgroundTag":"missing-required-argument","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}