{"record":{"id":"67dd9b3bd01d02c3","repo":"hcengineering/platform","slug":"container-not-found","errorCode":null,"errorMessage":"Container not found","messagePattern":"Container not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/net/packages/client/src/agent.ts","lineNumber":84,"sourceCode":"        for (const uuid of uuids) {\n          const container = await this.agent.getContainer(uuid)\n          if (container === undefined) {\n            console.error(`Container ${uuid} not found`)\n            continue\n          }\n          // Events will be routed via connectionId\n          container.connect(client, async (data) => {\n            await this.rpcServer.send(client, [uuid, data])\n          })\n        }\n        await send(connected)\n        break\n      }\n      case opNames.disconnect: {\n        const uuid = params.uuid as ContainerUuid\n        const container = await this.agent.getContainer(uuid)\n        if (container === undefined) {\n          throw new Error('Container not found')\n        }\n        container.disconnect(client)\n        await send('ok')\n        break\n      }\n      case opNames.sendContainer: {\n        const target: ContainerUuid = params[0]\n        const operation: string = params[1]\n        const data: any = params[2]\n\n        const container = await this.agent.getContainer(target)\n        if (container === undefined) {\n          throw new Error('Container not found')\n        }\n        await send(await container.request(operation, data, client))\n        break\n      }\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/net/packages/client/src/agent.ts#L66-L102","documentation":"The network client agent's requestHandler processes the 'disconnect' operation and looks up the target container via agent.getContainer(uuid). If no container with that UUID exists locally, it throws 'Container not found'. This guards against disconnect requests targeting containers that were never created or already terminated.","triggerScenarios":"Sending opNames.disconnect with a params.uuid that does not match any container on the agent: container already terminated, wrong UUID, or the disconnect op races with concurrent termination.","commonSituations":"Double-disconnect from client retry logic; disconnecting after a container crash/stop; UUID mistyped or copied from a different agent.","solutions":["Check the container exists via getContainer before sending the disconnect op","Treat the error as 'already disconnected' and ignore/retry idempotently","Refresh the container list from the agent to get valid UUIDs","Fix UUID plumbing so disconnect uses the uuid returned at container creation"],"exampleFix":"// before\nawait client.request('disconnect', { uuid })\n// after\nconst container = await agent.getContainer(uuid)\nif (container !== undefined) {\n  await client.request('disconnect', { uuid })\n}","handlingStrategy":"validation","validationCode":"const container = await agent.getContainer(uuid)\nif (container === undefined) {\n  // already disconnected/terminated; skip\n}","typeGuard":"function containerExists(c: Awaited<ReturnType<typeof agent.getContainer>>): c is NonNullable<typeof c> {\n  return c !== undefined\n}","tryCatchPattern":"try {\n  await client.request(opNames.disconnect, { uuid })\n} catch (e) {\n  if (e instanceof Error && e.message === 'Container not found') {\n    // treat as already-disconnected, ignore\n  } else { throw e }\n}","preventionTips":["Make disconnect idempotent in caller code","Check getContainer before issuing disconnect","Track terminated container UUIDs","Avoid double-disconnect retry logic"],"tags":["container","lifecycle","disconnect","unknown-uuid"],"backgroundTag":"container-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}