{"record":{"id":"d2405af6ee49892d","repo":"slimtoolkit/slim","slug":"no-pods","errorCode":null,"errorMessage":"no pods","messagePattern":"no pods","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/command/debug/handle_kubernetes_runtime.go","lineNumber":961,"sourceCode":"\tvar list []string\n\tfor _, status := range input {\n\t\tif status.State.Running != nil || status.State.Waiting != nil {\n\t\t\tlist = append(list, status.Name)\n\t\t}\n\t}\n\n\treturn list\n}\n\nfunc ensurePod(ctx context.Context, api *kubernetes.Clientset, nsName string, podName string) (*corev1.Pod, string, error) {\n\tif podName == \"\" {\n\t\tpods, err := api.CoreV1().Pods(nsName).List(ctx, metav1.ListOptions{})\n\t\tif err != nil {\n\t\t\treturn nil, \"\", err\n\t\t}\n\n\t\tif len(pods.Items) == 0 {\n\t\t\treturn nil, \"\", fmt.Errorf(\"no pods\")\n\t\t}\n\n\t\tpodName = pods.Items[0].Name\n\t}\n\n\tvar outputPod *corev1.Pod\n\tisPodRunning := func() (bool, error) {\n\t\tpod, err := api.CoreV1().Pods(nsName).Get(ctx, podName, metav1.GetOptions{})\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\n\t\tswitch pod.Status.Phase {\n\t\tcase corev1.PodRunning:\n\t\t\toutputPod = pod\n\t\t\treturn true, nil\n\t\tcase corev1.PodFailed, corev1.PodSucceeded:\n\t\t\treturn false, fmt.Errorf(\"pod is done\")","sourceCodeStart":943,"sourceCodeEnd":979,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/command/debug/handle_kubernetes_runtime.go#L943-L979","documentation":"ensurePod resolves the target pod. With no explicit pod name it lists pods in the namespace and takes the first; if the namespace contains zero pods it fails with 'no pods'. Nothing is running in the selected namespace for the tool to debug.","triggerScenarios":"HandleKubernetesRuntime / listDebuggableK8sContainersWithConfig / listK8sDebugContainersWithConfig call ensurePod with a namespace whose Pods().List returns an empty Items slice.","commonSituations":"Wrong namespace (workload lives in 'production' but you are in 'default'); all pods crashed/completed and were garbage-collected; deployments scaled to 0; kubeconfig pointing at an empty cluster.","solutions":["Pass the pod name explicitly to the command instead of relying on auto-detection.","Confirm with `kubectl get pods -n <ns>` that pods actually exist in that namespace.","Scale the workload back up (`kubectl scale deploy/<name> --replicas=1`) before debugging.","Switch to the correct namespace/cluster context via KUBECONFIG."],"exampleFix":"// before: empty namespace fallback\nslim debug <target> --namespace default\n// after\nslim debug myapp-5d7f8c6b9-x2klm --namespace production","handlingStrategy":"validation","validationCode":"ns=production\n[ \"$(kubectl get pods -n \"$ns\" --field-selector=status.phase=Running -o name | wc -l)\" -gt 0 ] || echo \"no running pods in $ns\"","typeGuard":null,"tryCatchPattern":"if err := runDebug(target); err != nil && strings.Contains(err.Error(), \"no pods\") {\n    // check namespace/scale and retry\n}","preventionTips":["Pass the pod name explicitly, never rely on first-pod auto-detection","Check kubectl get pods -n <ns> first","Ensure deployments are scaled up before debugging"],"tags":["kubernetes","pod","namespace"],"backgroundTag":"no-pods-found","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}