{"record":{"id":"835845d22e080b51","repo":"vxcontrol/pentagi","slug":"failed-to-list-images-w","errorCode":null,"errorMessage":"failed to list images: %w","messagePattern":"failed to list images: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/docker/client.go","lineNumber":1178,"sourceCode":"\treturn err\n}\n\nfunc (dc *dockerClient) CopyFromContainer(\n\tctx context.Context,\n\tcontainerID string,\n\tsrcPath string,\n) (io.ReadCloser, container.PathStat, error) {\n\tresult, err := dc.client.CopyFromContainer(ctx, containerID, client.CopyFromContainerOptions{SourcePath: srcPath})\n\treturn result.Content, result.Stat, err\n}\n\nfunc (dc *dockerClient) pullImage(ctx context.Context, imageName string) error {\n\tfilterArgs := make(client.Filters).Add(\"reference\", imageName)\n\timages, err := dc.client.ImageList(ctx, client.ImageListOptions{\n\t\tFilters: filterArgs,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to list images: %w\", err)\n\t}\n\n\tif imageExistsLocally := len(images.Items) > 0; imageExistsLocally {\n\t\treturn nil\n\t}\n\n\tdc.logger.WithContext(ctx).WithField(\"image\", imageName).Info(\"initiating image download from registry...\")\n\n\tpullStream, err := dc.client.ImagePull(ctx, imageName, client.ImagePullOptions{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to pull image: %w\", err)\n\t}\n\tdefer pullStream.Close()\n\n\t// drain pull stream to completion\n\tif _, err := io.Copy(io.Discard, pullStream); err != nil {\n\t\treturn fmt.Errorf(\"image download stream processing failed: %w\", err)\n\t}","sourceCodeStart":1160,"sourceCodeEnd":1196,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/docker/client.go#L1160-L1196","documentation":"pullImage first calls ImageList with a `reference` filter to check whether the image already exists locally. This error wraps a failure of that listing API call, so the local-existence check could not be performed and the pull is aborted before even attempting a download.","triggerScenarios":"dc.client.ImageList(ctx, client.ImageListOptions{Filters: filterArgs}) fails because the Docker daemon is unreachable, the socket is permission-denied, the reference filter string is malformed, or the daemon returned 500/timeout.","commonSituations":"DOCKER_HOST misconfigured or daemon not running; user not in the `docker` group (permission denied on /var/run/docker.sock); malformed image name (invalid tag/registry chars); remote daemon temporarily unavailable.","solutions":["Verify daemon connectivity: `docker ps` succeeds from the same environment","Fix permissions on the Docker socket (add user to `docker` group) or use rootless mode correctly","Validate the imageName is a well-formed reference (registry/repo:tag) — malformed filters fail the list call","Retry with backoff if the daemon was temporarily unavailable"],"exampleFix":"// before: socket permission denied\nimages, err := dc.client.ImageList(ctx, opts) // fails\n// after (host fix):\n// sudo usermod -aG docker $USER && newgrp docker\nimages, err := dc.client.ImageList(ctx, opts) // succeeds","handlingStrategy":"retry","validationCode":"// validate image reference shape before calling\nif ref, err := reference.ParseNormalizedNamed(imageName); err != nil {\n    return fmt.Errorf(\"invalid image reference %q: %w\", imageName, err)\n} else {\n    _ = ref\n}","typeGuard":null,"tryCatchPattern":"if err := pullImage(ctx, imageName); err != nil {\n    if strings.Contains(err.Error(), \"failed to list images\") {\n        // daemon-side issue: check connectivity then retry with backoff\n        time.Sleep(2 * time.Second)\n        return pullImage(ctx, imageName)\n    }\n    return err\n}","preventionTips":["Verify DOCKER_HOST and socket permissions at startup","Validate image reference strings before filtering","Add user to docker group or run with appropriate socket access","Retry daemon 5xx/timeouts with exponential backoff"],"tags":["docker","image-pull","daemon","api"],"backgroundTag":"docker-daemon-unreachable","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}