{"record":{"id":"fdce452fc92d86a7","repo":"mastra-ai/mastra","slug":"dataset-not-found-args-id","errorCode":null,"errorMessage":"Dataset not found: ${args.id}","messagePattern":"Dataset not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/datasets/base.ts","lineNumber":107,"sourceCode":"   * if it also matches the tenancy filters — returns `null` on mismatch (never\n   * throws, to avoid leaking existence across tenants via error timing/text).\n   */\n  abstract getDatasetById(args: { id: string; filters?: DatasetTenancyFilters }): Promise<DatasetRecord | null>;\n  /**\n   * Delete a dataset. When `filters` is provided, the delete is a silent no-op\n   * if the row does not match the tenancy filters. Never throws on mismatch.\n   */\n  abstract deleteDataset(args: { id: string; filters?: DatasetTenancyFilters }): Promise<void>;\n  abstract listDatasets(args: ListDatasetsInput): Promise<ListDatasetsOutput>;\n\n  /**\n   * Update a dataset. Validates existing items against new schemas if schemas are changing.\n   * Subclasses implement _doUpdateDataset for actual storage operation.\n   */\n  async updateDataset(args: UpdateDatasetInput): Promise<DatasetRecord> {\n    const existing = await this.getDatasetById({ id: args.id, filters: args.filters });\n    if (!existing) {\n      throw new Error(`Dataset not found: ${args.id}`);\n    }\n\n    // Check if schemas are being added or modified\n    const inputSchemaChanging =\n      args.inputSchema !== undefined && JSON.stringify(args.inputSchema) !== JSON.stringify(existing.inputSchema);\n    const groundTruthSchemaChanging =\n      args.groundTruthSchema !== undefined &&\n      JSON.stringify(args.groundTruthSchema) !== JSON.stringify(existing.groundTruthSchema);\n\n    // If schemas changing, validate all existing items against new schemas\n    if (inputSchemaChanging || groundTruthSchemaChanging) {\n      const itemsResult = await this.listItems({\n        datasetId: args.id,\n        pagination: { page: 0, perPage: false }, // Get all items\n      });\n      const items = itemsResult.items;\n\n      if (items.length > 0) {","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/datasets/base.ts#L89-L125","documentation":"updateDataset() first fetches the dataset via getDatasetById; if no dataset exists for args.id (under the given filters), it throws a plain Error \"Dataset not found: <id>\" instead of attempting an update. It is a standard missing-resource guard.","triggerScenarios":"Calling storage.updateDataset({ id }) where the id doesn't exist, was already deleted, or is filtered out by args.filters (different workspace/scope filters hiding the record).","commonSituations":"Typo in dataset id, environment mismatch (dataset created in another DB/env), filters inadvertently excluding the record, race with a concurrent delete, storage adapter not pointed at the right database.","solutions":["Verify the id via getDatasetById/listDatasets before updating","Check the filters passed in updateDataset aren't excluding the dataset","Confirm you're connected to the same storage backend/environment where the dataset was created","Recreate the dataset if it was deleted"],"exampleFix":"// before\nawait storage.updateDataset({ id: 'ds_typo', inputSchema })\n// after\nconst ds = await storage.getDatasetById({ id: 'ds_typo' });\nif (ds) await storage.updateDataset({ id: 'ds_typo', inputSchema });","handlingStrategy":"validation","validationCode":"const ds = await storage.getDatasetById({ id: args.id, filters: args.filters });\nif (!ds) throw new Error(`dataset ${args.id} not found`);","typeGuard":"null","tryCatchPattern":"try {\n  await storage.updateDataset(args);\n} catch (e) {\n  if (e.message.startsWith('Dataset not found:')) { /* recreate or correct id/filters */ }\n  throw e;\n}","preventionTips":["Verify dataset existence before updates","Double-check filters match how the dataset was created","Keep dataset ids in typed constants/config, not string literals","Handle cross-environment id drift explicitly"],"tags":["storage","datasets","not-found","user-input"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}