{"record":{"id":"4f74b4e0e9ded47b","repo":"henrygd/beszel","slug":"container-inspect-request-failed-s","errorCode":null,"errorMessage":"container inspect request failed: %s","messagePattern":"container inspect request failed: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/docker.go","lineNumber":464,"sourceCode":"\n// parseDockerHealthStatus maps Docker health status strings to container.DockerHealth values\nfunc parseDockerHealthStatus(status string) (container.DockerHealth, bool) {\n\thealth, ok := container.DockerHealthStrings[strings.ToLower(strings.TrimSpace(status))]\n\treturn health, ok\n}\n\n// getPodmanContainerHealth fetches container health status from the container inspect endpoint.\n// Used for Podman which doesn't provide health status in the /containers/json endpoint as of March 2026.\n// https://github.com/containers/podman/issues/27786\nfunc (dm *dockerManager) getPodmanContainerHealth(containerID string) (container.DockerHealth, error) {\n\tresp, err := dm.client.Get(fmt.Sprintf(\"http://localhost/containers/%s/json\", url.PathEscape(containerID)))\n\tif err != nil {\n\t\treturn container.DockerHealthNone, err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn container.DockerHealthNone, fmt.Errorf(\"container inspect request failed: %s\", resp.Status)\n\t}\n\n\tvar inspectInfo struct {\n\t\tState struct {\n\t\t\tHealth struct {\n\t\t\t\tStatus string\n\t\t\t}\n\t\t}\n\t}\n\tif err := json.NewDecoder(resp.Body).Decode(&inspectInfo); err != nil {\n\t\treturn container.DockerHealthNone, err\n\t}\n\n\tif health, ok := parseDockerHealthStatus(inspectInfo.State.Health.Status); ok {\n\t\treturn health, nil\n\t}\n\n\treturn container.DockerHealthNone, nil","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/henrygd/beszel/blob/b38fb7dafa60812cc22e6a84ce313e94f1ce0a32/agent/docker.go#L446-L482","documentation":"getPodmanContainerHealth talks to the Podman/Docker-compatible REST socket to inspect a container and read its State.Health.Status. This error is thrown when the inspect HTTP request returns a non-200 status; the actual status text (e.g. '404 Not Found') is embedded in the message. It means the health data could not be fetched, not that the container is unhealthy.","triggerScenarios":"The HTTP GET of the container inspect endpoint (e.g. /containers/{id}/json via the Podman socket) returns any status other than 200 — typically 404 when the container ID does not exist on that socket, 403/401 when the socket denies access, or 500 from the daemon.","commonSituations":"Agent pointed at a Podman socket but the container was removed/restarted with a new ID; containers running under a different user's podman socket (rootless); insufficient permissions on /run/podman/podman.sock; API version mismatch returning an unexpected status.","solutions":["Verify the container ID/name actually exists on the socket being queried (podman ps)","Check socket permissions and that the agent user can access it (groups, SOCK_DIR env)","Confirm the DOCKER_HOST/PODMAN socket URL is correct and the daemon is running","Retry after transient daemon restarts; the stats loop will pick up health on the next tick"],"exampleFix":"// before: ambiguous handling of any failure\nhealth, err := getPodmanContainerHealth(ctr)\n// after: distinguish missing container from real errors\nhealth, err := getPodmanContainerHealth(ctr)\nif err != nil && strings.Contains(err.Error(), \"404\") {\n    health = container.DockerHealthNone // container gone\n} else if err != nil {\n    log.Warn(\"podman health check\", err)\n}","handlingStrategy":"fallback","validationCode":"// before relying on health, confirm the container exists on the socket\nresp, err := http.Get(sockBase + \"/containers/\" + id + \"/json\")\nif err != nil || resp.StatusCode != http.StatusOK {\n    // skip health for this container\n}","typeGuard":null,"tryCatchPattern":"health, err := getPodmanContainerHealth(id)\nif err != nil {\n    log.Warn(\"health unavailable\", \"err\", err)\n    health = container.DockerHealthNone\n}","preventionTips":["Check podman ps shows the container on the same socket the agent uses","Grant the agent user access to the podman/docker socket","Treat health as optional metadata; don't fail container stats when it is missing"],"tags":["http","podman","docker-socket"],"backgroundTag":"http-non-200-response","analyzedSha":"b38fb7dafa60812cc22e6a84ce313e94f1ce0a32","analyzedAt":"2026-08-31T15:10:10.149Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}