{"record":{"id":"d455b8d45e245789","repo":"hcengineering/platform","slug":"container-target-not-found-d455b8","errorCode":null,"errorMessage":"Container ${target} not found","messagePattern":"Container (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/net/packages/core/src/network.ts","lineNumber":110,"sourceCode":"    }))\n  }\n\n  async kinds (): Promise<ContainerKind[]> {\n    return Array.from(this._agents.values())\n      .map((it) => it.kinds)\n      .flatMap((it) => it)\n  }\n\n  async list (kind?: ContainerKind): Promise<ContainerRecord[]> {\n    return Array.from(this._containers.values())\n      .filter((it) => kind === undefined || it.record.kind === kind)\n      .map((it) => it.record)\n  }\n\n  async request (target: ContainerUuid, operation: string, data?: any): Promise<any> {\n    const container = this._containers.get(target)\n    if (container === undefined) {\n      throw new Error(`Container ${target} not found`)\n    }\n    return await container.agent?.api.request(target, operation, data)\n  }\n\n  async register (record: AgentRecord, agent: NetworkAgent): Promise<ContainerUuid[]> {\n    const newContainers: ContainerRecord[] = record.containers\n    const newContainersMap = new Map<ContainerUuid, ContainerRecordImpl>(\n      newContainers.map((record) => [\n        record.uuid,\n        {\n          record,\n          request: { kind: record.kind },\n          endpoint: record.endpoint,\n          clients: new Set<ClientUuid>([]),\n          agent: null as any // Temporarily\n        }\n      ])\n    )","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/net/packages/core/src/network.ts#L92-L128","documentation":"Network.request looks the target container up in the network's local _containers map before dispatching the operation to the owning agent. If the uuid is absent from the map the network throws, since it has no record of which agent hosts that container. This is the network-level equivalent of the agent's own container-not-found error.","triggerScenarios":"Calling network.request(target, operation, data) with a uuid that was never registered via network.register/agent join, or one that was removed (container released, agent disconnected, records pruned).","commonSituations":"Agent left the network and its containers were dropped; client kept a uuid across a network restart; name/uuid mismatch between environments (dev vs prod networks); sending requests before register() finished populating _containers.","solutions":["Ensure the container was created through this network (register/agent.join) before requesting it; re-create it if the network restarted.","Re-resolve the container: request a new instance of the same kind so the network can schedule it and return a fresh uuid.","Check that the owning agent is still connected; reconnect it so its container records are re-registered.","Persist uuids only across restarts if the network does; otherwise treat uuids as ephemeral and refetch."],"exampleFix":"// before\nawait network.request(unknownUuid, 'run', payload) // throws if pruned\n// after\nconst uuid = (await network.getContainer(clientId, kind, options)).uuid\nawait network.request(uuid, 'run', payload)","handlingStrategy":"try-catch","validationCode":"if (!network.hasContainer?.(uuid)) {\n  const fresh = await network.getContainer(clientId, kind, options)\n  // use fresh.uuid instead of the stale one\n}","typeGuard":"function containerExists(uuid: string, network: Network): boolean {\n  return typeof uuid === 'string' && network.containers?.has?.(uuid) === true\n}","tryCatchPattern":"try {\n  return await network.request(uuid, op, data)\n} catch (e) {\n  if ((e as Error).message === `Container ${uuid} not found`) {\n    const rec = await network.getContainer(clientId, kind, options)\n    return await network.request(rec.record.uuid, op, data)\n  }\n  throw e\n}","preventionTips":["Re-resolve containers after any network/agent restart instead of reusing persisted uuids.","Listen for agent-disconnect events and invalidate cached uuids of that agent's containers.","Release containers explicitly when done to keep uuid usage intentional.","Keep one network instance per environment to avoid uuid confusion across dev/prod."],"tags":["network","container","lookup","request-routing"],"backgroundTag":"container-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}