{"record":{"id":"2026d830a6c01dd4","repo":"coder/code-server","slug":"entry-is-required","errorCode":null,"errorMessage":"entry is required","messagePattern":"entry is required","errorType":"http","errorClass":"HttpError","httpStatus":400,"severity":"warning","filePath":"src/node/vscodeSocket.ts","lineNumber":59,"sourceCode":"  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\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 {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/coder/code-server/blob/51f90a376b42e217b38937410fe2855e0c1db87e/src/node/vscodeSocket.ts#L41-L77","documentation":"Thrown by the POST /add-session route of the editor session manager socket server when req.body.entry is missing. It is an HttpError (400) handled by errorHandler. The route registers an EditorSessionEntry (workspace + socketPath) so the entry payload is mandatory.","triggerScenarios":"A POST /add-session whose JSON body has no 'entry' key, an empty body, or a non-JSON body that express.json() failed to parse (leaving req.body undefined). The handler reads req.body?.entry and rejects falsy values.","commonSituations":"The VS Code extension posting a partial payload; a Content-Type mismatch (e.g. text/plain) so the JSON middleware does not populate req.body; a schema change where the client still posts the entry at the top level instead of nested under 'entry'.","solutions":["POST a JSON body shaped as { \"entry\": { \"workspace\": {...}, \"socketPath\": \"...\" } } with header Content-Type: application/json.","Verify express.json() is parsing the body (correct Content-Type, valid JSON).","Ensure the client uses the current AddSessionRequest schema with the nested 'entry' field.","Log req.body in development to confirm the middleware populated it."],"exampleFix":"// before\nreq.write(JSON.stringify({ workspace, socketPath }))\n// after\nreq.write(JSON.stringify({ entry: { workspace, socketPath } }))","handlingStrategy":"validation","validationCode":"// Before POST /add-session\nconst body = { entry: { workspace, socketPath } }\nif (!body.entry || !body.entry.socketPath) throw new Error('entry is required')\nawait post('/add-session', body)","typeGuard":"function isAddSessionRequest(b: unknown): b is { entry: EditorSessionEntry } {\n  return typeof b === 'object' && b !== null\n    && typeof (b as any).entry === 'object'\n    && typeof (b as any).entry?.socketPath === 'string'\n}","tryCatchPattern":"try {\n  await post('/add-session', { entry })\n} catch (e) {\n  if (/entry is required/.test(e.message)) throw new Error('payload shape mismatch')\n}","preventionTips":["Send Content-Type: application/json with valid JSON.","Nest the entry under the 'entry' key per AddSessionRequest.","Validate the entry has workspace + socketPath before posting.","Keep the client schema in sync with EditorSessionEntry."],"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"}