{"record":{"id":"a93b532749697050","repo":"mastra-ai/mastra","slug":"datasets-storage-not-configured","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/dataset.ts","lineNumber":69,"sourceCode":"   */\n  #scope?: DatasetTenancyFilters;\n\n  constructor(id: string, mastra: Mastra, scope?: DatasetTenancyFilters) {\n    this.id = id;\n    this.#mastra = mastra;\n    this.#scope = scope;\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":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/datasets/dataset.ts#L51-L87","documentation":"The Dataset class resolves its datasets storage domain through the Mastra instance. This MastraError (DATASETS_STORAGE_NOT_CONFIGURED, STORAGE/USER) is thrown when no storage is configured on the Mastra instance, so there is nowhere to read/write dataset records. It is a user configuration error surfaced on first storage access.","triggerScenarios":"Calling any Dataset API (store, datasetsStore, item/versions/experiments methods) on a Mastra instance created without a `storage` option, and #getDatasetsStore() finding this.#mastra.getStorage() returns undefined.","commonSituations":"Constructing `new Mastra()` without storage in scripts or examples; forgetting storage when copying a minimal agent setup; storage removed during a refactor while Dataset usage remained.","solutions":["Configure storage on your Mastra instance: new Mastra({ storage: new MastraStorage(...) }).","Use a storage adapter that supports the datasets domain (e.g. libsql, pg, upstash).","Verify getStorage() on your Mastra instance returns a value before using Dataset APIs."],"exampleFix":"// before\nconst mastra = new Mastra({ agents });\n// after\nconst mastra = new Mastra({ agents, storage: new MastraLibsqlStorage({ url: 'file:./mastra.db' }) });","handlingStrategy":"validation","validationCode":"if (!mastra.getStorage()) throw new Error('Configure storage on the Mastra instance before using Dataset APIs');","typeGuard":"null","tryCatchPattern":"try { await dataset.listItems(); } catch (e) { if (e?.id === 'DATASETS_STORAGE_NOT_CONFIGURED') { /* surface config error */ } else throw e; }","preventionTips":["Always pass storage when constructing Mastra in any project that uses datasets","Add a startup assertion that mastra.getStorage() is truthy","Use a shared Mastra factory so storage config cannot be omitted"],"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"}