{"record":{"id":"485ded7ebacee600","repo":"mastra-ai/mastra","slug":"error-message-485ded","errorCode":null,"errorMessage":"error.message","messagePattern":"error\\.message","errorType":"http","errorClass":"HTTPException","httpStatus":null,"severity":"error","filePath":"packages/server/src/server/handlers/datasets.ts","lineNumber":163,"sourceCode":"  responseType: 'json',\n  queryParamSchema: paginationQuerySchema,\n  responseSchema: listDatasetsResponseSchema,\n  summary: 'List all datasets',\n  description: 'Returns a paginated list of all datasets',\n  tags: ['Datasets'],\n  requiresAuth: true,\n  handler: async ({ mastra, ...params }) => {\n    assertDatasetsAvailable();\n    try {\n      const { page, perPage } = params;\n      const result = await mastra.datasets.list({ page: page ?? 0, perPage: perPage ?? 10 });\n      return {\n        datasets: result.datasets as any,\n        pagination: result.pagination,\n      };\n    } catch (error) {\n      if (error instanceof MastraError) {\n        throw new HTTPException(getHttpStatusForMastraError(error.id) as StatusCode, { message: error.message });\n      }\n      return handleError(error, 'Error listing datasets');\n    }\n  },\n});\n\nexport const CREATE_DATASET_ROUTE = createRoute({\n  method: 'POST',\n  path: '/datasets',\n  responseType: 'json',\n  bodySchema: createDatasetBodySchema,\n  responseSchema: datasetResponseSchema,\n  summary: 'Create a new dataset',\n  description: 'Creates a new dataset with the specified name and optional metadata',\n  tags: ['Datasets'],\n  requiresAuth: true,\n  handler: async ({ mastra, ...params }) => {\n    assertDatasetsAvailable();","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/datasets.ts#L145-L181","documentation":"This is not a distinct error type but the generic rethrow path in the list-datasets route handler. When mastra.datasets.list() (or the storage layer behind it) throws a MastraError, the handler converts it to an HTTPException whose message is the underlying error.message and whose status code is derived from the error ID (getHttpStatusForMastraError). Non-MastraError failures go to handleError and surface as a generic 500. The developer-facing symptom is an HTTP response whose body text is the raw internal dataset error message.","triggerScenarios":"GET /api/datasets where the underlying storage/dataset domain throws a MastraError — e.g. a storage adapter failure, a tenant/project resolution error, or any DATASET_* / storage error ID raised while listing datasets. Also occurs when @mastra/core is below the version that registers the datasets feature and the core layer rejects the call.","commonSituations":"Misconfigured storage adapter (database down, wrong connection string), upgrading server packages without upgrading @mastra/core to >= 1.4.0 so the datasets domain is unavailable, or organizationId/projectId tenancy filters pointing at a nonexistent project.","solutions":["Read error.message in the HTTP response — it is the underlying MastraError message; fix the storage/domain issue it describes.","Verify @mastra/core is >= 1.4.0 so the datasets feature is registered (the handler gates with coreFeatures.has('datasets')).","Check the storage adapter connection/configuration used by mastra storage.","If the error is not a MastraError it returns 500 via handleError — enable server logs to see the original stack."],"exampleFix":"// before: response is a bare message string\nconst res = await fetch('/api/datasets');\nconst msg = await res.text();\n// after: handle non-OK statuses explicitly and surface the message\nif (!res.ok) {\n  const { message } = await res.json();\n  throw new Error(`List datasets failed (${res.status}): ${message}`);\n}","handlingStrategy":"try-catch","validationCode":"import { execSync } from 'node:child_process';\nconst version = JSON.parse(execSync('npm ls @mastra/core --json').toString())\n  .dependencies['@mastra/core'].version;\nif (version < '1.4.0') throw new Error('datasets feature requires @mastra/core >= 1.4.0');","typeGuard":"function isMastraHttpError(e: unknown): e is { status: number; message: string } {\n  return typeof e === 'object' && e !== null && 'status' in e && 'message' in e;\n}","tryCatchPattern":"try {\n  const res = await fetch('/api/datasets');\n  if (!res.ok) {\n    const body = await res.json();\n    // body.message is the underlying MastraError message\n    throw new DatasetApiError(res.status, body.message);\n  }\n  return res.json();\n} catch (e) {\n  if (e instanceof DatasetApiError && e.status >= 500) {\n    // storage/domain failure — retry with backoff or surface infra alert\n  }\n  throw e;\n}","preventionTips":["Keep @mastra/core and @mastra/server versions in lockstep (>= 1.4.0 for datasets).","Health-check the storage adapter before app startup.","Always read the JSON body's message field on non-2xx responses — it is the real domain error.","Alert on 500s from list endpoints; they indicate non-MastraError infra failures."],"tags":["http","server","datasets","mastra-error"],"backgroundTag":"mastra-error-propagated-as-http-exception","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}