{"record":{"id":"a26d87b8542f5073","repo":"hcengineering/platform","slug":"container-target-not-found","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/agent.ts","lineNumber":254,"sourceCode":"        await (await current).container.terminate() // Await promise before terminating\n      } else {\n        await current.container.terminate()\n      }\n      return\n    }\n\n    // Also check stateless containers\n    const stateless = this.statelessContainers.get(uuid)\n    if (stateless !== undefined) {\n      this.statelessContainers.delete(uuid)\n      await stateless.container.terminate()\n    }\n  }\n\n  async request (target: ContainerUuid, operation: string, data?: any): Promise<any> {\n    const container = await this.getContainer(target)\n    if (container === undefined) {\n      throw new Error(`Container ${target} not found`)\n    }\n    return await container.request(operation, data)\n  }\n}\n","sourceCodeStart":236,"sourceCodeEnd":259,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/net/packages/core/src/agent.ts#L236-L259","documentation":"Agent.request resolves the target container via getContainer and delegates the operation to it. When the container UUID is not known to this agent, it throws instead of calling request on undefined. It indicates the caller is addressing a container this agent instance cannot see or no longer holds.","triggerScenarios":"Calling agent.request(target, operation, data) with a ContainerUuid that was never registered on this agent, was released, or belongs to another agent/network node. getContainer returning undefined for the uuid.","commonSituations":"Using a stale container uuid after release/agent restart; routing a request to the wrong agent in a multi-agent deployment; copy-pasted or truncated uuid; race where the container record was evicted between obtaining the uuid and calling request.","solutions":["Confirm the uuid is the one returned by the same agent instance (e.g. from agent.api.get(kind) or the network record), not one from another node.","Re-acquire the container: call get/create again to obtain a fresh uuid, then retry the request.","Check the agent's registered containers/records to see whether the target exists and under which agent.","In distributed setups, route the request through the network/discovery layer instead of the local agent so the correct agent handles it."],"exampleFix":"// before\nconst result = await agent.request(staleUuid, 'compute', data)\n// after\nconst [uuid] = await agent.api.get(kind, options)\nconst result = await agent.request(uuid, 'compute', data)","handlingStrategy":"try-catch","validationCode":"const known = await agent.getContainer?.(target) // or track uuids you created\nif (known === undefined) {\n  console.warn('agent does not know container', target, '- re-acquiring')\n}","typeGuard":"function isKnownContainer(uuid: string | undefined): uuid is string {\n  return typeof uuid === 'string' && createdUuids.has(uuid)\n}","tryCatchPattern":"try {\n  return await agent.request(target, op, data)\n} catch (e) {\n  if ((e as Error).message === `Container ${target} not found`) {\n    const [uuid] = await agent.api.get(kind, options) // re-acquire fresh container\n    return await agent.request(uuid, op, data)\n  }\n  throw e\n}","preventionTips":["Treat container uuids as ephemeral: always fetch from the same agent instance you call request on.","Clear cached uuids when an agent is released or restarted.","Log uuid provenance (which agent returned it) to catch cross-agent routing mistakes.","Prefer network-level request routing in multi-agent setups instead of direct agent calls."],"tags":["container","lookup","request-routing","uuid"],"backgroundTag":"container-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}