{"record":{"id":"f6358ff54682cbaa","repo":"amir20/dozzle","slug":"container-not-found-w-f6358f","errorCode":null,"errorMessage":"container not found: %w","messagePattern":"container not found: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/tools_logs.go","lineNumber":37,"sourceCode":"\tLevel       string `json:\"level\"`\n\tQuery       string `json:\"query\"`\n\tRegex       string `json:\"regex\"`\n\tInverse     bool   `json:\"inverse\"`\n}\n\nfunc executeFetchContainerLogs(ctx context.Context, argsJSON string, deps ToolDeps) (*pb.CallToolResponse, error) {\n\tvar args fetchLogsArgs\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\thostID, containerID, note, 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\tstart := time.Now().Add(-1 * time.Hour)\n\tend := time.Now()\n\tif args.Start != \"\" {\n\t\tt, err := time.Parse(time.RFC3339, args.Start)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid start time format (expected RFC3339): %w\", err)\n\t\t}\n\t\tstart = t\n\t}\n\tif args.End != \"\" {\n\t\tt, err := time.Parse(time.RFC3339, args.End)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid end time format (expected RFC3339): %w\", err)\n\t\t}\n\t\tend = t\n\t}","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/cloud/tools_logs.go#L19-L55","documentation":"executeFetchContainerLogs resolves the container reference and calls deps.HostService.FindContainer. If no container matches the resolved host/ID pair, the underlying lookup error is wrapped as \"container not found\" and returned instead of logs.","triggerScenarios":"Calling fetch_container_logs with a containerId that no longer exists, is running on a different host than the host argument, or a name that does not resolve on that host.","commonSituations":"Container restarted and got a new ID; agent querying a remote host that is down (so the container appears missing); k8s mode where the pod was rescheduled; using the container display name instead of its actual ID.","solutions":["Refresh the container ID via find_containers immediately before fetching logs.","Confirm the host argument matches the host the container currently runs on.","Verify the container exists and is running (`docker ps` or the Dozzle UI); check that the host's Docker client connection is healthy."],"exampleFix":"// before: logs for a recreated container's old id\nfetch_container_logs({\"containerId\":\"oldid\"})\n// after\nfind_containers({\"name\":\"web\"}) -> fetch_container_logs({\"containerId\": <current id>, \"host\": <hostId>})","handlingStrategy":"validation","validationCode":"const list = await callTool(\"find_containers\", JSON.stringify({ name: targetName }));\nif (!list.containers?.length) throw new Error(`container '${targetName}' not found; cannot fetch logs`);\nconst { id, host } = list.containers[0];","typeGuard":"function logTarget(c) {\n  return typeof c?.id === \"string\" && typeof c?.host === \"string\" ? { containerId: c.id, host: c.host } : null;\n}","tryCatchPattern":"try {\n  return await callTool(\"fetch_container_logs\", JSON.stringify({ containerId: id, host }));\n} catch (e) {\n  if (String(e).includes(\"container not found\")) {\n    // container recreated or host wrong; refresh find_containers and retry once\n  }\n  throw e;\n}","preventionTips":["Fetch logs by a freshly resolved container ID, never a cached one.","Confirm the host argument matches the container's current host.","Handle container restarts: re-resolve IDs after any lifecycle event."],"tags":["docker","logs","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"}