coder/code-server · warning · HttpError
entry is required
Error message
entry is required
What it means
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.
Source
Thrown at src/node/vscodeSocket.ts:59
router.use(express.json())
router.get<{}, GetSessionResponse | string | unknown, undefined, { filePath?: string }>(
"/session",
async (req, res) => {
const filePath = req.query.filePath
if (!filePath) {
throw new HttpError("filePath is required", HttpCode.BadRequest)
}
const socketPath = await editorSessionManager.getConnectedSocketPath(filePath)
const response: GetSessionResponse = { socketPath }
res.json(response)
},
)
router.post<{}, string, AddSessionRequest | undefined>("/add-session", async (req, res) => {
const entry = req.body?.entry
if (!entry) {
throw new HttpError("entry is required", HttpCode.BadRequest)
}
editorSessionManager.addSession(entry)
res.status(200).send("session added")
})
router.post<{}, string, DeleteSessionRequest | undefined>("/delete-session", async (req, res) => {
const socketPath = req.body?.socketPath
if (!socketPath) {
throw new HttpError("socketPath is required", HttpCode.BadRequest)
}
editorSessionManager.deleteSession(socketPath)
res.status(200).send("session deleted")
})
router.use(errorHandler)
const server = http.createServer(router)
try {View on GitHub (pinned to 51f90a376b)
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.
Example fix
// before
req.write(JSON.stringify({ workspace, socketPath }))
// after
req.write(JSON.stringify({ entry: { workspace, socketPath } })) Defensive patterns
Strategy: validation
Validate before calling
// Before POST /add-session
const body = { entry: { workspace, socketPath } }
if (!body.entry || !body.entry.socketPath) throw new Error('entry is required')
await post('/add-session', body) Type guard
function isAddSessionRequest(b: unknown): b is { entry: EditorSessionEntry } {
return typeof b === 'object' && b !== null
&& typeof (b as any).entry === 'object'
&& typeof (b as any).entry?.socketPath === 'string'
} Try / catch
try {
await post('/add-session', { entry })
} catch (e) {
if (/entry is required/.test(e.message)) throw new Error('payload shape mismatch')
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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'.
Related errors
- filePath is required
- socketPath is required
- Invalid port
- --idle-timeout-seconds must be greater than 60 seconds.
- Unsupported auth type ${req.args.auth}
AI-assisted analysis of coder/code-server@51f90a376b (2026-08-12).
Data as JSON: /api/errors/2026d830a6c01dd4.
Report an issue: GitHub.