{"record":{"id":"790bb6af5fa4caa8","repo":"coder/code-server","slug":"filepath-is-required","errorCode":null,"errorMessage":"filePath is required","messagePattern":"filePath is required","errorType":"http","errorClass":"HttpError","httpStatus":400,"severity":"warning","filePath":"src/node/vscodeSocket.ts","lineNumber":48,"sourceCode":"\ninterface GetSessionResponse {\n  socketPath?: string\n}\n\nexport async function makeEditorSessionManagerServer(\n  codeServerSocketPath: string,\n  editorSessionManager: EditorSessionManager,\n): Promise<http.Server> {\n  const router = express()\n\n  router.use(express.json())\n\n  router.get<{}, GetSessionResponse | string | unknown, undefined, { filePath?: string }>(\n    \"/session\",\n    async (req, res) => {\n      const filePath = req.query.filePath\n      if (!filePath) {\n        throw new HttpError(\"filePath is required\", HttpCode.BadRequest)\n      }\n      const socketPath = await editorSessionManager.getConnectedSocketPath(filePath)\n      const response: GetSessionResponse = { socketPath }\n      res.json(response)\n    },\n  )\n\n  router.post<{}, string, AddSessionRequest | undefined>(\"/add-session\", async (req, res) => {\n    const entry = req.body?.entry\n    if (!entry) {\n      throw new HttpError(\"entry is required\", HttpCode.BadRequest)\n    }\n    editorSessionManager.addSession(entry)\n    res.status(200).send(\"session added\")\n  })\n\n  router.post<{}, string, DeleteSessionRequest | undefined>(\"/delete-session\", async (req, res) => {\n    const socketPath = req.body?.socketPath","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/coder/code-server/blob/51f90a376b42e217b38937410fe2855e0c1db87e/src/node/vscodeSocket.ts#L30-L66","documentation":"Thrown by the GET /session route of the editor session manager socket server (src/node/vscodeSocket.ts) when req.query.filePath is missing. It is an HttpError with status 400 and is funneled through the registered errorHandler middleware so the client receives a structured HTTP 400 rather than a crash.","triggerScenarios":"An HTTP GET to /session on the code-server socket without a ?filePath= query parameter, or with an empty value. The route's only purpose is to map a file path to a connected VS Code socket, so filePath is mandatory.","commonSituations":"A client (e.g. the EditorSessionManagerClient or a CLI integration) that forgot to append ?filePath=; a URL-encoding bug that strips the parameter; a stale client built against an older API that did not require filePath.","solutions":["Always include the query parameter: GET /session?filePath=<encodeURIComponent(absolutePath)>.","In EditorSessionManagerClient.getConnectedSocketPath, confirm the filePath argument is a non-empty string before the request.","URL-encode the path to avoid characters being parsed out of the query string.","Upgrade any custom client to match the current /session contract."],"exampleFix":"// before\nhttp.get({ path: '/session', socketPath })\n// after\nhttp.get({ path: '/session?filePath=' + encodeURIComponent(filePath), socketPath })","handlingStrategy":"validation","validationCode":"// Before calling GET /session\nfunction sessionPath(socketPath: string, filePath: string): string {\n  if (!filePath) throw new Error('filePath is required')\n  return '/session?filePath=' + encodeURIComponent(filePath)\n}","typeGuard":"function hasFilePath(q: unknown): q is { filePath: string } {\n  return typeof q === 'object' && q !== null && typeof (q as any).filePath === 'string' && (q as any).filePath.length > 0\n}","tryCatchPattern":"try {\n  const res = await get('/session?filePath=' + encodeURIComponent(filePath))\n  if (res.statusCode === 400) throw new Error('filePath missing or invalid')\n} catch (e) { /* handle */ }","preventionTips":["Always append ?filePath=<encoded absolute path> to /session requests.","URL-encode the path value.","Reuse EditorSessionManagerClient rather than hand-rolling the request.","Validate filePath is a non-empty string before requesting."],"tags":["vscode-socket","session-manager","validation","bad-request"],"backgroundTag":null,"analyzedSha":"51f90a376b42e217b38937410fe2855e0c1db87e","analyzedAt":"2026-08-12T11:27:34.273Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}