{"record":{"id":"91a18760f9e36856","repo":"amir20/dozzle","slug":"failed-to-list-pods-in-namespace-s-w","errorCode":null,"errorMessage":"failed to list pods in namespace %s: %w","messagePattern":"failed to list pods in namespace (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/k8s/client.go","lineNumber":472,"sourceCode":"\nfunc (k *K8sClient) ListContainers(ctx context.Context, labels container.ContainerLabels) ([]container.Container, error) {\n\tpodLabels, metadataLabels := splitK8sFilters(labels)\n\tselector := \"\"\n\tif podLabels.Exists() {\n\t\tfor key, values := range podLabels {\n\t\t\tfor _, value := range values {\n\t\t\t\tif selector != \"\" {\n\t\t\t\t\tselector += \",\"\n\t\t\t\t}\n\t\t\t\tselector += fmt.Sprintf(\"%s=%s\", key, value)\n\t\t\t}\n\t\t}\n\t\tlog.Debug().Str(\"selector\", selector).Msg(\"Listing containers with labels\")\n\t}\n\tcontainerList := lop.Map(k.namespace, func(namespace string, index int) lo.Tuple2[[]container.Container, error] {\n\t\tpods, err := k.Clientset.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{LabelSelector: selector})\n\t\tif err != nil {\n\t\t\treturn lo.T2[[]container.Container, error](nil, fmt.Errorf(\"failed to list pods in namespace %s: %w\", namespace, err))\n\t\t}\n\t\tvar containers []container.Container\n\t\tfor _, pod := range pods.Items {\n\t\t\tfor _, c := range k.podToContainers(ctx, &pod) {\n\t\t\t\tif metadataLabels.Exists() && !matchesContainerLabels(c.Labels, metadataLabels) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tcontainers = append(containers, c)\n\t\t\t}\n\t\t}\n\t\treturn lo.T2[[]container.Container, error](containers, nil)\n\t})\n\n\tvar containers []container.Container\n\tvar lastError error\n\tsuccess := false\n\tfor _, t2 := range containerList {\n\t\titems, err := t2.Unpack()","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/k8s/client.go#L454-L490","documentation":"ListContainers queries pods across each of the client's configured namespaces and wraps any per-namespace list failure with the namespace name. Commonly caused by RBAC denial (pods not listable), a bad label selector, or an unreachable API server for that namespace.","triggerScenarios":"Thrown at internal/k8s/client.go:472 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check RBAC rules allow listing pods in the given namespace (ClusterRole with pods list/get/watch).","Verify the label selector values are valid Kubernetes label values (no invalid characters).","Confirm the namespace exists and the API server is reachable from the Dozzle pod."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}