{"record":{"id":"dd3fcb0d529ac60a","repo":"amir20/dozzle","slug":"container-not-found-w-dd3fcb","errorCode":null,"errorMessage":"container not found: %w","messagePattern":"container not found: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/tools_containers.go","lineNumber":182,"sourceCode":"}\n\nfunc executeInspectContainer(argsJSON string, deps ToolDeps) (*pb.CallToolResponse, error) {\n\tvar args inspectContainerArgs\n\tif err := json.Unmarshal([]byte(argsJSON), &args); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse arguments: %w\", err)\n\t}\n\t// Read-only: resolve an ambiguous name in one shot rather than erroring and\n\t// forcing a find_containers round-trip. The note is discarded here because\n\t// inspect already returns the concrete id/name/state, which is itself the\n\t// disambiguation — no need to mangle those structured fields with prose.\n\thostID, containerID, _, err := resolveContainerRefRead(args.ContainerID, args.Host, deps)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcs, err := deps.HostService.FindContainer(hostID, containerID, deps.Labels)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"container not found: %w\", err)\n\t}\n\n\tc := cs.Container\n\treturn &pb.CallToolResponse{\n\t\tSuccess: true,\n\t\tResult: &pb.CallToolResponse_InspectContainer{InspectContainer: &pb.InspectContainerResult{\n\t\t\tId:            c.ID,\n\t\t\tName:          c.Name,\n\t\t\tImage:         c.Image,\n\t\t\tCommand:       c.Command,\n\t\t\tCreated:       c.Created.UTC().Format(time.RFC3339),\n\t\t\tStartedAt:     c.StartedAt.UTC().Format(time.RFC3339),\n\t\t\tFinishedAt:    formatTimeOrEmpty(c.FinishedAt),\n\t\t\tState:         c.State,\n\t\t\tHealth:        c.Health,\n\t\t\tHostName:      resolveHostName(c.Host, buildHostNameMap(deps.HostService)),\n\t\t\tHostId:        c.Host,\n\t\t\tLabels:        c.Labels,","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/cloud/tools_containers.go#L164-L200","documentation":"executeInspectContainer resolves the container reference and calls deps.HostService.FindContainer. When no matching container exists on the resolved host, the underlying error is wrapped as \"container not found\" and surfaced to the cloud tool caller.","triggerScenarios":"Calling inspect_container with a containerId that is unknown, removed, belongs to another host, or an ambiguous name that does not resolve on the given host.","commonSituations":"Inspecting a container right after it was recreated (ID changed); multi-host setups where the host argument points at the wrong node; name-based lookup when dev.dozzle.name labels changed.","solutions":["Re-resolve with find_containers to obtain the current container ID and host before inspecting.","Verify the host argument; in multi-host deployments the container only lives on one node.","Confirm with `docker ps` that the container exists and is running on the expected Docker host."],"exampleFix":"// before: inspecting by removed id\ninspect_container({\"containerId\":\"deadbeef\"})\n// after\nfind_containers({\"name\":\"api\"}) -> inspect_container({\"containerId\": <fresh id>, \"host\": <hostId>})","handlingStrategy":"validation","validationCode":"const list = await callTool(\"find_containers\", JSON.stringify({ name: targetName }));\nconst match = list.containers?.find(c => c.name === targetName);\nif (!match) throw new Error(`no container named '${targetName}'; nothing to inspect`);","typeGuard":"function isInspectable(c) {\n  return typeof c?.id === \"string\" && c.id.length > 0 && typeof c?.host === \"string\";\n}","tryCatchPattern":"try {\n  return await callTool(\"inspect_container\", JSON.stringify({ containerId: match.id, host: match.host }));\n} catch (e) {\n  if (String(e).includes(\"container not found\")) {\n    // id went stale; re-run find_containers and retry once\n  }\n  throw e;\n}","preventionTips":["Always derive containerId/host from a fresh find_containers result.","Avoid inspecting by display name if labels changed recently.","In k8s mode, re-check pod existence after rescheduling events."],"tags":["docker","cloud-tools","not-found"],"backgroundTag":"entity-not-found","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}