mastra-ai/mastra · error · MastraError
DATASETS_STORAGE_NOT_CONFIGURED
DATASETS_STORAGE_NOT_CONFIGURED
Error message
Storage not configured. Configure storage in Mastra instance.
What it means
The datasets manager caches a DatasetsStorage handle obtained from the Mastra instance; if mastra.getStorage() returns undefined (no storage configured at all), #getDatasetsStore throws DATASETS_STORAGE_NOT_CONFIGURED. Any datasets manager operation that lazily resolves the store (e.g. store(), get()) hits this first.
Source
Thrown at packages/core/src/datasets/manager.ts:51
export class DatasetsManager {
#mastra: Mastra;
#datasetsStore?: DatasetsStorage;
#experimentsStore?: ExperimentsStorage;
constructor(mastra: Mastra) {
this.#mastra = mastra;
}
// ---------------------------------------------------------------------------
// Lazy storage resolution
// ---------------------------------------------------------------------------
async #getDatasetsStore(): Promise<DatasetsStorage> {
if (this.#datasetsStore) return this.#datasetsStore;
const storage = this.#mastra.getStorage();
if (!storage) {
throw new MastraError({
id: 'DATASETS_STORAGE_NOT_CONFIGURED',
text: 'Storage not configured. Configure storage in Mastra instance.',
domain: 'STORAGE',
category: 'USER',
});
}
const store = await storage.getStore('datasets');
if (!store) {
throw new MastraError({
id: 'DATASETS_STORE_NOT_AVAILABLE',
text: 'Datasets store not available. Ensure your storage adapter provides a datasets domain.',
domain: 'STORAGE',
category: 'USER',
});
}
this.#datasetsStore = store;View on GitHub (pinned to 75dd419e61)
Solutions
- Pass a storage instance to the Mastra constructor.
- Ensure it's the same instance used elsewhere (mastra.getStorage()) so domains resolve consistently.
- For quick starts, use a bundled adapter (e.g. LibSQLStore) instead of running without storage.
- Guard dataset operations behind a config check in app bootstrap and fail loudly at startup.
Example fix
// before
const mastra = new Mastra({ agents });
await mastra.getDatasets().create({ name: 'evals' }); // throws
// after
const mastra = new Mastra({ agents, storage: new PgStore({ connectionString }) });
await mastra.getDatasets().create({ name: 'evals' }); Defensive patterns
Strategy: validation
Validate before calling
if (!mastra.getStorage()) throw new Error('Mastra instance requires storage for datasets'); Type guard
function hasStorage(m: Mastra): boolean { return !!m.getStorage(); } Try / catch
try {
const ds = await datasets.get({ id });
} catch (err) {
if (err?.id === 'DATASETS_STORAGE_NOT_CONFIGURED') {
throw new ConfigError('Datasets require `storage` in new Mastra({...})');
}
throw err;
} Prevention
- Always pass `storage` when constructing Mastra if you use datasets or experiments.
- Centralize Mastra construction so storage can't be omitted accidentally.
- Add an integration test that touches the datasets store to catch missing config early.
- Check the constructor options in copied example code — storage is often stripped.
When it happens
Trigger: Any datasets API call (creating datasets, get, experimentsStore) on a Mastra instance constructed without a `storage` option.
Common situations: Forgetting to add storage to new Mastra({...}); test setups without persistent storage; examples/copied code where storage was stripped out.
Related errors
- DATASETS_STORAGE_NOT_CONFIGURED
- AcpAgent does not support resuming suspended generate calls
- ACP prompt stopped before completing: ${response.stopReason}
- 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/347f51f277672fdf.
Report an issue: GitHub.