{"record":{"id":"4700f93b4da808e2","repo":"hcengineering/platform","slug":"unknown-method-4700f9","errorCode":null,"errorMessage":"Unknown method","messagePattern":"Unknown method","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/collaborator/src/server.ts","lineNumber":182,"sourceCode":"    }\n\n    const documentId = req.params.id\n    if (documentId === undefined || documentId === '') {\n      const response: RpcErrorResponse = {\n        error: 'Missing document id'\n      }\n      res.status(400).send(response)\n      return\n    }\n\n    const request = req.body as RpcRequest\n\n    const method = methods[request.method]\n    if (method === undefined) {\n      const response: RpcErrorResponse = {\n        error: 'Unknown method'\n      }\n      res.status(400).send(response)\n      return\n    }\n\n    const context = await getContext(rawToken, token)\n\n    rpcCtx.info('rpc', { method: request.method, connectionId: context.connectionId, mode: token.extra?.mode ?? '' })\n    await rpcCtx.with(\n      '/rpc',\n      {\n        source: token.extra?.service ?? '🤦‍♂️user',\n        method: request.method\n      },\n      async (ctx) => {\n        try {\n          const response: RpcResponse = await rpcCtx.with(request.method, {}, (ctx) => {\n            return method(ctx, context, documentId, request.payload, { hocuspocus, storageAdapter, transformer })\n          })\n          res.status(200).send(response)","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/server/collaborator/src/server.ts#L164-L200","documentation":"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'}.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nbody: JSON.stringify({ name: 'push', params })\n// after\nbody: JSON.stringify({ method: 'push', params }),\nheaders: { 'Content-Type': 'application/json' }","handlingStrategy":"validation","validationCode":"const KNOWN_METHODS = ['push', 'pull', 'ping'] // must mirror the server's methods map\nfunction isKnownMethod(body: unknown): body is { method: string; params?: unknown } {\n  return typeof body === 'object' && body !== null && 'method' in body &&\n    typeof (body as any).method === 'string' && KNOWN_METHODS.includes((body as any).method)\n}","typeGuard":"function isRpcRequest(x: unknown): x is RpcRequest {\n  return typeof x === 'object' && x !== null && typeof (x as RpcRequest).method === 'string'\n}","tryCatchPattern":"if (!isKnownMethod(requestBody)) {\n  throw new Error(`Unknown RPC method: ${JSON.stringify(requestBody)}`)\n}\nconst res = await postRpc(url, requestBody)\nif (res.status === 400) {\n  const { error } = await res.json()\n  if (error === 'Unknown method') throw new Error('Method not registered on collaborator server')\n}","preventionTips":["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."],"tags":["http-400","rpc","validation"],"backgroundTag":"rpc-unknown-method","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}