{"record":{"id":"246fe85b441631a9","repo":"hcengineering/platform","slug":"missing-document-id","errorCode":null,"errorMessage":"Missing document id","messagePattern":"Missing document id","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/collaborator/src/server.ts","lineNumber":171,"sourceCode":"      res.status(401).send({ error: 'Unauthorized' })\n      return\n    }\n\n    const rawToken = authHeader.split(' ')[1]\n    let token: Token\n    try {\n      token = decodeToken(rawToken)\n    } catch {\n      res.status(401).send({ error: 'Unauthorized' })\n      return\n    }\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(","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/server/collaborator/src/server.ts#L153-L189","documentation":"The /rpc/:id route requires the :id path parameter to identify the target document. When the id is missing or an empty string, the server responds HTTP 400 with {error:'Missing document id'}.","triggerScenarios":"POST to /rpc/ (trailing empty id) or /rpc with the document id omitted from the URL path.","commonSituations":"URL template interpolation with an undefined/empty document id; route builders dropping the id; clients hardcoding '/rpc/' without substituting the id.","solutions":["Include the document/tx id in the URL path: POST /rpc/<documentId>.","Validate the document id is a non-empty string before building the request URL.","Fix string interpolation that yields an empty id (e.g. undefined template variable)."],"exampleFix":"// before\nconst url = `/rpc/${docId ?? ''}`\n// after\nif (!docId) throw new Error('documentId is required')\nconst url = `/rpc/${docId}`","handlingStrategy":"validation","validationCode":"function buildRpcUrl(base: string, documentId: string | undefined): string {\n  if (typeof documentId !== 'string' || documentId === '') throw new Error('documentId is required')\n  return `${base}/rpc/${documentId}`\n}","typeGuard":"function hasDocumentId(id: unknown): id is string {\n  return typeof id === 'string' && id.length > 0\n}","tryCatchPattern":"try {\n  const url = buildRpcUrl(base, docId)\n  return await postRpc(url, body)\n} catch (e) {\n  if (e instanceof MissingDocumentIdError) {\n    console.error('Cannot call RPC without a document id'); return null\n  }\n  throw e\n}","preventionTips":["Validate document ids at the point where RPC URLs are constructed.","Use typed wrappers around RPC calls instead of raw string interpolation.","Check for undefined variables before template interpolation in URL builders."],"tags":["http-400","validation","rpc"],"backgroundTag":"missing-path-parameter","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}