{"record":{"id":"ce35211af25dcecd","repo":"amir20/dozzle","slug":"container-not-found-w","errorCode":null,"errorMessage":"container not found: %w","messagePattern":"container not found: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/tools_actions.go","lineNumber":35,"sourceCode":"func executeContainerAction(ctx context.Context, name string, argsJSON string, deps ToolDeps) (*pb.CallToolResponse, error) {\n\tvar args containerActionArgs\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\n\taction, err := resolveAction(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\thostID, containerID, err := resolveContainerRef(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\tif err := cs.Action(ctx, action); err != nil {\n\t\treturn nil, fmt.Errorf(\"action failed: %w\", err)\n\t}\n\n\tmessage := fmt.Sprintf(\"Successfully %s container %s.\", pastTense(action), cs.Container.Name)\n\n\treturn &pb.CallToolResponse{\n\t\tSuccess: true,\n\t\tResult: &pb.CallToolResponse_Action{Action: &pb.ActionResult{\n\t\t\tSuccess:     true,\n\t\t\tContainerId: cs.Container.ID,\n\t\t\tAction:      string(action),\n\t\t\tMessage:     message,\n\t\t}},\n\t}, nil\n}","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/cloud/tools_actions.go#L17-L53","documentation":"After parsing arguments and resolving the action, executeContainerAction resolves the target via HostService.FindContainer; any failure is wrapped as 'container not found: %w'. The container or host could not be located with the given IDs and label filters, so the action is aborted.","triggerScenarios":"Calling an action tool with a container_id or host_id that does not exist, an ID belonging to another host, or a container excluded by the configured label filters (deps.Labels).","commonSituations":"LLM hallucinating container IDs from stale context; container removed/recreated so its ID changed; agent host offline; containers filtered out by dev.dozzle.* label restrictions.","solutions":["List current containers via the ListContainers/FindContainers tool and use a fresh ID","Verify host_id matches a connected host returned by ListHosts","Check configured label filters (deps.Labels) are not excluding the container","If the container was recreated, use the new container ID or its name-based lookup"],"exampleFix":"// before: stale ID from earlier session\n{\"container_id\": \"e9034...\", \"host_id\": \"old-host\"}\n// after: resolve first, then act\n// hits := ListContainers(); use hits[0].ContainerId","handlingStrategy":"validation","validationCode":"// resolve the container first and surface a fresh ID\nhosts, _ := deps.HostService.ListHosts()\nfound := false\nfor _, h := range hosts {\n    if h.ID == args.HostID { found = true }\n}\nif !found { return fmt.Errorf(\"unknown host_id %q\", args.HostID) }","typeGuard":null,"tryCatchPattern":"cs, err := deps.HostService.FindContainer(hostID, containerID, labels)\nif err != nil {\n    return toolErrorResponse(\"container not found; call ListContainers for valid IDs\")\n}","preventionTips":["Always resolve container IDs via ListContainers/FindContainers right before acting","Re-resolve IDs after container restarts or recreations","Check label filters are not hiding the target container","Confirm the host_id exists and its agent is connected"],"tags":["cloud","tools","containers","not-found","actions"],"backgroundTag":"resource-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"}