{"record":{"id":"788919530e392b4a","repo":"mastra-ai/mastra","slug":"no-workspace-configured","errorCode":null,"errorMessage":"No workspace configured","messagePattern":"No workspace configured","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"packages/server/src/server/handlers/workspace.ts","lineNumber":847,"sourceCode":"  path: '/workspaces/:workspaceId/index',\n  responseType: 'json',\n  pathParamSchema: workspaceIdPathParams,\n  bodySchema: indexBodySchema,\n  responseSchema: indexResponseSchema,\n  summary: 'Index content for search',\n  description: 'Indexes content for later search operations',\n  tags: ['Workspace'],\n  handler: async ({ mastra, path, content, metadata, workspaceId }) => {\n    try {\n      requireWorkspaceV1Support();\n\n      if (!path || content === undefined) {\n        throw new HTTPException(400, { message: 'Path and content are required' });\n      }\n\n      const workspace = await getWorkspaceById(mastra, workspaceId);\n      if (!workspace) {\n        throw new HTTPException(404, { message: 'No workspace configured' });\n      }\n\n      const canSearch = workspace.canBM25 || workspace.canVector;\n      if (!canSearch) {\n        throw new HTTPException(400, { message: 'Workspace does not have search configured' });\n      }\n\n      await workspace.index(path, content, { metadata });\n\n      return {\n        success: true,\n        path,\n      };\n    } catch (error) {\n      return handleWorkspaceError(error, 'Error indexing content');\n    }\n  },\n});","sourceCodeStart":829,"sourceCodeEnd":865,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/workspace.ts#L829-L865","documentation":"The index route (POST /workspaces/:workspaceId/index) throws this 404 when `getWorkspaceById(mastra, workspaceId)` returns no workspace — i.e. no workspace is registered under that ID (or none is configured at all). Indexing requires an existing workspace instance to delegate to workspace.index().","triggerScenarios":"POSTing to /workspaces/:id/index with a workspaceId that is not registered in the Mastra instance; Mastra constructed without any workspace; typo'd workspaceId path param; server started before workspace registration code ran.","commonSituations":"Copy-pasting a workspaceId from another deployment/environment; workspace configured only in local dev but not in the deployed Mastra config; version mismatch where the deployment doesn't support workspaces v1; client caching a stale workspaceId after server restart with new IDs.","solutions":["Use a workspaceId that is actually registered on the running Mastra instance (check the workspace config passed to new Mastra({ workspaces: ... })).","Verify the server deployment includes workspace configuration (env-specific config drift).","List available workspaces or check server startup logs to confirm registration.","If the workspace is created dynamically, create/register it before calling index."],"exampleFix":"// before\nawait fetch(`/api/workspaces/typo-ws/index`, { method: 'POST', ... });\n// after\nawait fetch(`/api/workspaces/${registeredWorkspaceId}/index`, { method: 'POST', ... });","handlingStrategy":"validation","validationCode":"// Confirm the workspace exists before indexing\nconst wsRes = await fetch(`/api/workspaces/${wsId}/fs/list?path=${encodeURIComponent('/')}`);\nif (wsRes.status === 404) {\n  throw new Error(`Workspace ${wsId} is not configured on this server`);\n}","typeGuard":"function isKnownWorkspaceId(id: unknown): id is string {\n  return typeof id === 'string' && knownWorkspaceIds.includes(id);\n}","tryCatchPattern":"try {\n  await indexContent(wsId, path, content);\n} catch (e) {\n  if (isHTTPException(e, 404) && e.message === 'No workspace configured') {\n    // re-read workspace registration / correct the id, then retry once\n  } else throw e;\n}","preventionTips":["Keep workspaceIds in a shared constant/config, not string literals","Verify registration at server startup (fail fast if workspaces missing)","Avoid env drift: use the same Mastra workspace config across environments","Check GET workspace routes to confirm the id is live before writing"],"tags":["http-404","workspace","configuration","rest-api"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}