hcengineering/platform · error
Unknown method
Error message
Unknown method
What it means
The /rpc/:id endpoint looks up the requested procedure in its registered methods map. If request.body.method is not registered (or the body is not a valid RpcRequest), the server responds HTTP 400 with {error:'Unknown method'}.
Source
Thrown at server/collaborator/src/server.ts:182
}
const documentId = req.params.id
if (documentId === undefined || documentId === '') {
const response: RpcErrorResponse = {
error: 'Missing document id'
}
res.status(400).send(response)
return
}
const request = req.body as RpcRequest
const method = methods[request.method]
if (method === undefined) {
const response: RpcErrorResponse = {
error: 'Unknown method'
}
res.status(400).send(response)
return
}
const context = await getContext(rawToken, token)
rpcCtx.info('rpc', { method: request.method, connectionId: context.connectionId, mode: token.extra?.mode ?? '' })
await rpcCtx.with(
'/rpc',
{
source: token.extra?.service ?? '🤦♂️user',
method: request.method
},
async (ctx) => {
try {
const response: RpcResponse = await rpcCtx.with(request.method, {}, (ctx) => {
return method(ctx, context, documentId, request.payload, { hocuspocus, storageAdapter, transformer })
})
res.status(200).send(response)View on GitHub (pinned to 63e28dc964)
Solutions
- Use a method name registered on the collaborator server (verify against the methods map).
- Send Content-Type: application/json and a body of the form {method, params} so request.method parses correctly.
- Align client and server versions so the called method exists in the deployed build.
Example fix
// before
body: JSON.stringify({ name: 'push', params })
// after
body: JSON.stringify({ method: 'push', params }),
headers: { 'Content-Type': 'application/json' } Defensive patterns
Strategy: validation
Validate before calling
const KNOWN_METHODS = ['push', 'pull', 'ping'] // must mirror the server's methods map
function isKnownMethod(body: unknown): body is { method: string; params?: unknown } {
return typeof body === 'object' && body !== null && 'method' in body &&
typeof (body as any).method === 'string' && KNOWN_METHODS.includes((body as any).method)
} Type guard
function isRpcRequest(x: unknown): x is RpcRequest {
return typeof x === 'object' && x !== null && typeof (x as RpcRequest).method === 'string'
} Try / catch
if (!isKnownMethod(requestBody)) {
throw new Error(`Unknown RPC method: ${JSON.stringify(requestBody)}`)
}
const res = await postRpc(url, requestBody)
if (res.status === 400) {
const { error } = await res.json()
if (error === 'Unknown method') throw new Error('Method not registered on collaborator server')
} Prevention
- Share a single generated method-name enum between client and server.
- Always send Content-Type: application/json on RPC calls.
- Pin client and server versions together to avoid method skew.
When it happens
Trigger: POST /rpc/:id whose JSON body has a method field not present in the server's methods registry, or a missing/empty method field, or a body that is not JSON (request.method resolves to undefined).
Common situations: Client/server version skew (method renamed or not yet deployed); typos in method names; forgetting to set Content-Type: application/json so req.body is undefined.
Related errors
- Missing document id
- Failed to load server config
- getDisplayMedia not supported
- No screen access granted
- platform.status.BadRequest
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/4700f93b4da808e2.
Report an issue: GitHub.