hcengineering/platform · error

Container not found

Error message

Container not found

What it means

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.

Source

Thrown at foundations/net/packages/client/src/agent.ts:84

        for (const uuid of uuids) {
          const container = await this.agent.getContainer(uuid)
          if (container === undefined) {
            console.error(`Container ${uuid} not found`)
            continue
          }
          // Events will be routed via connectionId
          container.connect(client, async (data) => {
            await this.rpcServer.send(client, [uuid, data])
          })
        }
        await send(connected)
        break
      }
      case opNames.disconnect: {
        const uuid = params.uuid as ContainerUuid
        const container = await this.agent.getContainer(uuid)
        if (container === undefined) {
          throw new Error('Container not found')
        }
        container.disconnect(client)
        await send('ok')
        break
      }
      case opNames.sendContainer: {
        const target: ContainerUuid = params[0]
        const operation: string = params[1]
        const data: any = params[2]

        const container = await this.agent.getContainer(target)
        if (container === undefined) {
          throw new Error('Container not found')
        }
        await send(await container.request(operation, data, client))
        break
      }

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Check the container exists via getContainer before sending the disconnect op
  2. Treat the error as 'already disconnected' and ignore/retry idempotently
  3. Refresh the container list from the agent to get valid UUIDs
  4. Fix UUID plumbing so disconnect uses the uuid returned at container creation

Example fix

// before
await client.request('disconnect', { uuid })
// after
const container = await agent.getContainer(uuid)
if (container !== undefined) {
  await client.request('disconnect', { uuid })
}
Defensive patterns

Strategy: validation

Validate before calling

const container = await agent.getContainer(uuid)
if (container === undefined) {
  // already disconnected/terminated; skip
}

Type guard

function containerExists(c: Awaited<ReturnType<typeof agent.getContainer>>): c is NonNullable<typeof c> {
  return c !== undefined
}

Try / catch

try {
  await client.request(opNames.disconnect, { uuid })
} catch (e) {
  if (e instanceof Error && e.message === 'Container not found') {
    // treat as already-disconnected, ignore
  } else { throw e }
}

Prevention

When it happens

Trigger: 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.

Common situations: Double-disconnect from client retry logic; disconnecting after a container crash/stop; UUID mistyped or copied from a different agent.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/67dd9b3bd01d02c3. Report an issue: GitHub.