hcengineering/platform · error · Status
unknownStatus(err.message)
Error message
unknownStatus(err.message)
What it means
When a method handler throws inside serveAccount, the catch block converts the raw error message into a Status via unknownStatus(err.message) and returns it as a 400 response. This entry exists because the thrown message did not match any known status mapping, so the service wraps whatever text arrived into an error response generically.
Source
Thrown at server/account-service/src/index.ts:440
}
ctx.res.writeHead(400, KEEP_ALIVE_HEADERS)
ctx.res.end(JSON.stringify(response))
return
}
try {
const result = await method(_ctx, db, branding, request, token, meta)
const body = JSON.stringify(result)
ctx.res.writeHead(200, KEEP_ALIVE_HEADERS)
ctx.res.end(body)
} catch (err: any) {
const response = {
id: request.id,
error: unknownStatus(err.message)
}
ctx.res.writeHead(400, KEEP_ALIVE_HEADERS)
ctx.res.end(JSON.stringify(response))
}
},
{ method: request.method }
)
})
app.use(router.routes()).use(router.allowedMethods())
const server = app.listen(ACCOUNT_PORT, () => {
console.log(`server started on port ${ACCOUNT_PORT}`)
})
const close = (): void => {
onClose?.()
void accountsDb.then(([, closeAccountsDb]) => {
closeAccountsDb()
})View on GitHub (pinned to 63e28dc964)
Solutions
- Inspect the err.message in the 400 response body — it contains the original error text
- Fix the root cause in the method handler that threw (check service logs for the stack)
- If the message should be a known status, add/register it in the status mapping used by unknownStatus
- Throw Status objects (not raw strings) from handlers so they map correctly
Example fix
// before
throw new Error('user not found')
// after
throw new Status(Severity.ERROR, platform.status.NotFound, { user: id }) Defensive patterns
Strategy: try-catch
Validate before calling
// validate inputs expected by the handler before calling RPC
if (!request || typeof request.method !== 'function') throw new Error('invalid request') Try / catch
try {
const res = await rpc(method, args)
} catch (e) {
const status = e?.error // unknownStatus(err.message) output
console.error('RPC failed:', status?.message ?? e.message)
} Prevention
- Throw structured Status objects from handlers, not raw strings/Errors
- Register all handler-thrown messages in the status mapping
- Wrap each method body with its own try/catch and meaningful Status
- Alert on 400 responses whose error text doesn't match a known status
When it happens
Trigger: Any uncaught exception inside a method handler invoked by serveAccount — e.g. DB errors, validation failures, or thrown strings — reaches this catch and gets funneled through unknownStatus(err.message).
Common situations: Handler code throws a plain string or an error whose message isn't in the status registry; unhandled promise rejection in a method; network/DB outage causing raw driver errors to bubble up as 400s.
Related errors
- text (response body)
- platform.status.ConnectionClosed
- HTTP error ${res.status}
- result.error
- platform.status.BadRequest
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/9672dd072eb73480.
Report an issue: GitHub.