{"record":{"id":"e861e56cd3061efc","repo":"coder/code-server","slug":"socketpath-is-required","errorCode":null,"errorMessage":"socketPath is required","messagePattern":"socketPath is required","errorType":"http","errorClass":"HttpError","httpStatus":400,"severity":"warning","filePath":"src/node/vscodeSocket.ts","lineNumber":68,"sourceCode":"      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\n    if (!socketPath) {\n      throw new HttpError(\"socketPath is required\", HttpCode.BadRequest)\n    }\n    editorSessionManager.deleteSession(socketPath)\n    res.status(200).send(\"session deleted\")\n  })\n\n  router.use(errorHandler)\n\n  const server = http.createServer(router)\n  try {\n    await listen(server, { socket: codeServerSocketPath })\n  } catch (e) {\n    logger.warn(`Could not create socket at ${codeServerSocketPath}`)\n  }\n  return server\n}\n\nexport class EditorSessionManager {\n  // Map from socket path to EditorSessionEntry.","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/coder/code-server/blob/51f90a376b42e217b38937410fe2855e0c1db87e/src/node/vscodeSocket.ts#L50-L86","documentation":"Thrown by the POST /delete-session route of the editor session manager socket server when req.body.socketPath is missing. It is an HttpError (400) routed through errorHandler. The route deletes a tracked editor session by its socket path, so the path is mandatory.","triggerScenarios":"A POST /delete-session whose JSON body lacks the 'socketPath' field, has an empty body, or whose body was not parsed as JSON. The handler reads req.body?.socketPath and rejects falsy values.","commonSituations":"A cleanup hook posting an empty body on shutdown; a Content-Type that defeats express.json(); a client schema drift where the field was renamed (e.g. 'path' instead of 'socketPath').","solutions":["POST { \"socketPath\": \"<the-socket-path>\" } with Content-Type: application/json.","Ensure the client sends the field with the exact name 'socketPath'.","Confirm express.json() parsed the body (valid JSON + correct Content-Type).","Align the client with the DeleteSessionRequest interface."],"exampleFix":"// before\nreq.write(JSON.stringify({ path: sock }))\n// after\nreq.write(JSON.stringify({ socketPath: sock }))","handlingStrategy":"validation","validationCode":"// Before POST /delete-session\nif (!socketPath) throw new Error('socketPath is required')\nawait post('/delete-session', { socketPath })","typeGuard":"function isDeleteSessionRequest(b: unknown): b is { socketPath: string } {\n  return typeof b === 'object' && b !== null && typeof (b as any).socketPath === 'string' && (b as any).socketPath.length > 0\n}","tryCatchPattern":"try {\n  await post('/delete-session', { socketPath })\n} catch (e) {\n  if (/socketPath is required/.test(e.message)) throw new Error('missing socketPath in payload')\n}","preventionTips":["Always include a non-empty socketPath in the delete body.","Use the exact field name 'socketPath'.","Send Content-Type: application/json.","Idempotently skip deletion when the path is unknown rather than posting an empty body."],"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"}