mastra-ai/mastra · error · Error
DatasetsStorage not configured. Configure storage in Mastra
Error message
DatasetsStorage not configured. Configure storage in Mastra instance.
What it means
runExperiment supports a storage-backed data path when a datasetId is given; that path requires a datasets store to be configured on the Mastra instance. This plain Error is thrown when datasetId is provided but datasetsStore is undefined, i.e. storage was not configured in the Mastra constructor.
Source
Thrown at packages/core/src/datasets/experiment/index.ts:255
id,
datasetVersion: null,
input: dataItem.input,
groundTruth: dataItem.groundTruth,
expectedTrajectory: dataItem.expectedTrajectory,
requestContext: dataItem.requestContext,
metadata: dataItem.metadata,
resumeSteps: dataItem.resumeSteps,
resumeData: dataItem.resumeData,
toolMocks: dataItem.toolMocks,
unmockedToolPolicy: dataItem.unmockedToolPolicy,
scorerIds: dataItem.scorerIds,
};
});
datasetVersion = null;
} else if (datasetId) {
// Storage-backed data path (existing)
if (!datasetsStore) {
throw new Error('DatasetsStorage not configured. Configure storage in Mastra instance.');
}
datasetRecord = await datasetsStore.getDatasetById({ id: datasetId, filters: config.filters });
if (!datasetRecord) {
throw new MastraError({
id: 'DATASET_NOT_FOUND',
text: `Dataset not found: ${datasetId}`,
domain: 'STORAGE',
category: 'USER',
});
}
datasetVersion = version ?? datasetRecord.version;
const versionItems = await datasetsStore.getItemsByVersion({
datasetId,
version: datasetVersion,
});
View on GitHub (pinned to 75dd419e61)
Solutions
- Configure storage on the Mastra instance (pass a storage config/datasets store in the Mastra constructor)
- If the data is available inline, pass `data` instead of datasetId so no store is needed
- Verify you are calling runExperiment on the same Mastra instance that has storage attached, not a bare/default instance
Example fix
// before
const mastra = new Mastra({ agents: { myAgent } });
mastra.runExperiment({ datasetId: 'ds_123', ... });
// after
const mastra = new Mastra({ agents: { myAgent }, storage: new MastraStorage({ ... }) });
mastra.runExperiment({ datasetId: 'ds_123', ... }); Defensive patterns
Strategy: validation
Validate before calling
const store = mastra.getStorage?.(); // or inspect your Mastra constructor options
if (!store && config.datasetId) {
throw new Error('datasetId requires storage configured on the Mastra instance');
} Try / catch
try {
await runExperiment(config);
} catch (err) {
if (err instanceof Error && err.message.includes('DatasetsStorage not configured')) {
// construct Mastra with storage, or switch to inline data
} else throw err;
} Prevention
- Always configure storage on the Mastra instance when using datasets
- Use inline `data` for experiments that don't need persistence
- Centralize Mastra construction so storage is never omitted
- Add a startup assertion that storage is present in dataset-dependent services
When it happens
Trigger: Calling runExperiment (directly or via executeRun/startExperiment/startExperimentAsync) with a datasetId while the Mastra instance was constructed without a datasets/storage configuration.
Common situations: Running experiments against storage-backed datasets in an app that only used in-memory defaults; forgetting the storage option when instantiating Mastra; moving an experiment runner script into a service without wiring storage.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- AcpAgent does not support resuming suspended generate calls
- ACP prompt stopped before completing: ${response.stopReason}
- Auth0 domain and audience are required, please provide them
- MastraAuthBetterAuth needs a database to build its own bette
- [Slack] Failed to resolve Mastra storage. Ensure your Mastra
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/19c2fb1097b67395.
Report an issue: GitHub.