{"record":{"id":"347f51f277672fdf","repo":"mastra-ai/mastra","slug":"datasets-storage-not-configured-347f51","errorCode":"DATASETS_STORAGE_NOT_CONFIGURED","errorMessage":"Storage not configured. Configure storage in Mastra instance.","messagePattern":"Storage not configured\\. Configure storage in Mastra instance\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/datasets/manager.ts","lineNumber":51,"sourceCode":"export class DatasetsManager {\n  #mastra: Mastra;\n  #datasetsStore?: DatasetsStorage;\n  #experimentsStore?: ExperimentsStorage;\n\n  constructor(mastra: Mastra) {\n    this.#mastra = mastra;\n  }\n\n  // ---------------------------------------------------------------------------\n  // Lazy storage resolution\n  // ---------------------------------------------------------------------------\n\n  async #getDatasetsStore(): Promise<DatasetsStorage> {\n    if (this.#datasetsStore) return this.#datasetsStore;\n\n    const storage = this.#mastra.getStorage();\n    if (!storage) {\n      throw new MastraError({\n        id: 'DATASETS_STORAGE_NOT_CONFIGURED',\n        text: 'Storage not configured. Configure storage in Mastra instance.',\n        domain: 'STORAGE',\n        category: 'USER',\n      });\n    }\n\n    const store = await storage.getStore('datasets');\n    if (!store) {\n      throw new MastraError({\n        id: 'DATASETS_STORE_NOT_AVAILABLE',\n        text: 'Datasets store not available. Ensure your storage adapter provides a datasets domain.',\n        domain: 'STORAGE',\n        category: 'USER',\n      });\n    }\n\n    this.#datasetsStore = store;","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/datasets/manager.ts#L33-L69","documentation":"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.","triggerScenarios":"Any datasets API call (creating datasets, get, experimentsStore) on a Mastra instance constructed without a `storage` option.","commonSituations":"Forgetting to add storage to new Mastra({...}); test setups without persistent storage; examples/copied code where storage was stripped out.","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."],"exampleFix":"// before\nconst mastra = new Mastra({ agents });\nawait mastra.getDatasets().create({ name: 'evals' }); // throws\n// after\nconst mastra = new Mastra({ agents, storage: new PgStore({ connectionString }) });\nawait mastra.getDatasets().create({ name: 'evals' });","handlingStrategy":"validation","validationCode":"if (!mastra.getStorage()) throw new Error('Mastra instance requires storage for datasets');","typeGuard":"function hasStorage(m: Mastra): boolean { return !!m.getStorage(); }","tryCatchPattern":"try {\n  const ds = await datasets.get({ id });\n} catch (err) {\n  if (err?.id === 'DATASETS_STORAGE_NOT_CONFIGURED') {\n    throw new ConfigError('Datasets require `storage` in new Mastra({...})');\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["storage","configuration","datasets"],"backgroundTag":"storage-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}