{"record":{"id":"a4f557fdabb6761f","repo":"mastra-ai/mastra","slug":"path-is-required","errorCode":null,"errorMessage":"Path is required","messagePattern":"Path is required","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/workspace.ts","lineNumber":486,"sourceCode":"// Filesystem Routes\n// =============================================================================\n\nexport const WORKSPACE_FS_READ_ROUTE = createRoute({\n  method: 'GET',\n  path: '/workspaces/:workspaceId/fs/read',\n  responseType: 'json',\n  pathParamSchema: workspaceIdPathParams,\n  queryParamSchema: fsReadQuerySchema,\n  responseSchema: fsReadResponseSchema,\n  summary: 'Read file content',\n  description: 'Returns the content of a file at the specified path',\n  tags: ['Workspace'],\n  handler: async ({ mastra, path, encoding, workspaceId }) => {\n    try {\n      requireWorkspaceV1Support();\n\n      if (!path) {\n        throw new HTTPException(400, { message: 'Path is required' });\n      }\n\n      const workspace = await getWorkspaceById(mastra, workspaceId);\n      if (!workspace?.filesystem) {\n        throw new HTTPException(404, { message: 'No workspace filesystem configured' });\n      }\n\n      const decodedPath = decodeURIComponent(path);\n\n      // Check if path exists\n      if (!(await workspace.filesystem.exists(decodedPath))) {\n        throw new HTTPException(404, { message: `Path \"${decodedPath}\" not found` });\n      }\n\n      // Read file content\n      const content = await workspace.filesystem.readFile(decodedPath, {\n        encoding: (encoding as BufferEncoding) || 'utf-8',\n      });","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/workspace.ts#L468-L504","documentation":"Validation error thrown by the workspace file read handler (HTTP 400) when the request omits the required path parameter. The handler needs a path to locate the file within the workspace filesystem, so it rejects any request without one before doing any work.","triggerScenarios":"GET-ing the workspace file read route without the path query parameter (or with an empty string), e.g. a client bug that drops the query param after URL construction or an empty template variable.","commonSituations":"Template literal interpolation with an undefined path variable, URL builders that skip empty query params inconsistently, or manual curl testing that forgets ?path=.","solutions":["Add the path query parameter to the request, URL-encoded (e.g. ?path=%2Fsrc%2Fmain.ts).","Check the client code that builds the URL to ensure the path variable is defined and non-empty.","For empty-string paths, resolve to a real relative path (like '.' for listing) instead of sending nothing."],"exampleFix":"// before\nfetch(`/api/workspaces/${id}/file`);\n// after\nfetch(`/api/workspaces/${id}/file?path=${encodeURIComponent('src/main.ts')}`);","handlingStrategy":"validation","validationCode":"if (!path || typeof path !== 'string') {\n  throw new Error('readFile requires a non-empty workspace-relative path');\n}","typeGuard":"function hasPath(p: unknown): p is string {\n  return typeof p === 'string' && p.length > 0;\n}","tryCatchPattern":"try {\n  return await readWorkspaceFile({ workspaceId, path });\n} catch (e) {\n  if (isHttpException(e, 400) && e.message === 'Path is required') {\n    throw new Error(`Caller bug: path was not provided for workspace ${workspaceId}`);\n  }\n  throw e;\n}","preventionTips":["Validate path inputs at the edge of your client code before building requests.","Always pass paths through encodeURIComponent exactly once.","Avoid interpolating possibly-undefined variables into query strings."],"tags":["workspace","http-400","validation","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}