{"record":{"id":"83c7960cdc48e052","repo":"hcengineering/platform","slug":"unknown-method","errorCode":null,"errorMessage":"Unknown method","messagePattern":"Unknown method","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/net/packages/client/src/client.ts","lineNumber":178,"sourceCode":"      await send({ error: `Agent ${agentId} not found` })\n      return\n    }\n    switch (method) {\n      case opNames.getContainer:\n        await send(await agent.get(agentParams[0], agentParams[1]))\n        break\n      case opNames.listContainers:\n        await send(await agent.list(agentParams[0]))\n        break\n      case opNames.sendContainer:\n        await send(await agent.request(agentParams[0], agentParams[1], agentParams[2]))\n        break\n      case opNames.terminate:\n        await agent.terminate(agentParams[0] as ContainerUuid)\n        await send('')\n        break\n      default:\n        throw new Error('Unknown method')\n    }\n  }\n\n  async onEvent (event: NetworkEvent): Promise<void> {\n    // Handle container events\n    // In case of container stopped, agent stopped or endpoint changed, we need to update direct connections to be re-established.\n    await this.handleConnectionUpdates(event)\n\n    // Handle container removal for stateless containers - attempt to re-register\n    for (const containerEvent of event.containers) {\n      if (containerEvent.event === NetworkEventKind.removed) {\n        // Check if any of our agents have this container as stateless and need to re-register\n        for (const agentRecord of this._agents.values()) {\n          const agent = agentRecord.agent as any\n          const statelessContainers = agent.statelessContainers as Map<ContainerUuid, any> | undefined\n          if (statelessContainers !== undefined && statelessContainers.has(containerEvent.container.uuid)) {\n            console.log(\n              `HA: Container ${containerEvent.container.uuid} removed, attempting to re-register from agent ${agent.uuid}`","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/net/packages/client/src/client.ts#L160-L196","documentation":"The network client's requestHandler switch over agent/container operations reached default because the method did not match any known opNames case. It throws 'Unknown method'. Protocol mismatch between what the caller sent and the operations this client build supports.","triggerScenarios":"Sending a request through the client connection with a method name outside the supported set (hello/stop/terminate/etc.), e.g. a typo, unsupported op, or op removed in this version.","commonSituations":"Upgraded agents sending ops an older client doesn't understand; custom ops invented by app code but not implemented in the handler; case mismatches vs opNames constants.","solutions":["Only send methods defined in opNames constants","Sync client and agent/server package versions","Extend requestHandler with a case for the new operation if it's a legitimate op","Validate the method name client-side before issuing the request"],"exampleFix":"// before\nawait client.request('restart-agent', [uuid]) // not implemented\n// after\n// use a supported op or add a case in client.requestHandler first\nawait client.request(opNames.terminate, [uuid])","handlingStrategy":"validation","validationCode":"const allowed = Object.values(opNames) as string[]\nif (!allowed.includes(method)) {\n  throw new Error(`Unsupported client op: ${method}`)\n}","typeGuard":"function isClientOp(method: string): method is typeof opNames[keyof typeof opNames] {\n  return (Object.values(opNames) as string[]).includes(method)\n}","tryCatchPattern":"try {\n  await client.request(method, params)\n} catch (e) {\n  if (e instanceof Error && e.message === 'Unknown method') {\n    logProtocolMismatch(method)\n  } else { throw e }\n}","preventionTips":["Use opNames constants exclusively","Pin matching client/agent versions","Add cases for every op you send","Lint against hardcoded op strings"],"tags":["protocol","unknown-method","version-mismatch"],"backgroundTag":"unknown-rpc-method","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}