{"record":{"id":"ec8c46b170e0dd12","repo":"probelabs/goreplay","slug":"not-supported-k8s-scheme-allowed-values-namespa","errorCode":null,"errorMessage":"Not supported k8s scheme. Allowed values: [namespace/]pod/[pod_name], [namespace/]deployment/[deployment_name], [namespace/]daemonset/[daemonset_name], [namespace/]label/[label-name]/[label-value]","messagePattern":"Not supported k8s scheme\\. Allowed values: \\[namespace/\\]pod/\\[pod_name\\], \\[namespace/\\]deployment/\\[deployment_name\\], \\[namespace/\\]daemonset/\\[daemonset_name\\], \\[namespace/\\]label/\\[label-name\\]/\\[label-value\\]","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/capture/capture.go","lineNumber":309,"sourceCode":"//\t[namespace/]daemonset/[daemonset_name]\n//\t[namespace/]labelSelector/[selector]\n//\t[namespace/]fieldSelector/[selector]\nfunc k8sIPs(addr string) []string {\n\tconfig, err := rest.InClusterConfig()\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\n\t// creates the clientset\n\tclientset, err := kubernetes.NewForConfig(config)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\n\tsections := strings.Split(addr, \"/\")\n\n\tif len(sections) < 2 {\n\t\tpanic(\"Not supported k8s scheme. Allowed values: [namespace/]pod/[pod_name], [namespace/]deployment/[deployment_name], [namespace/]daemonset/[daemonset_name], [namespace/]label/[label-name]/[label-value]\")\n\t}\n\n\t// If no namespace passed, assume it is ALL\n\tswitch sections[0] {\n\tcase \"pod\", \"deployment\", \"daemonset\", \"labelSelector\", \"fieldSelector\":\n\t\tsections = append([]string{\"\"}, sections...)\n\t}\n\n\tnamespace, selectorType, selectorValue := sections[0], sections[1], sections[2]\n\n\tlabelSelector := \"\"\n\tfieldSelector := \"\"\n\n\tswitch selectorType {\n\tcase \"pod\":\n\t\tfieldSelector = \"metadata.name=\" + selectorValue\n\tcase \"deployment\":\n\t\tlabelSelector = \"app=\" + selectorValue","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/probelabs/goreplay/blob/251e45abd242886bb64ff2b2dc98789556b56330/internal/capture/capture.go#L291-L327","documentation":"k8sIPs expects addresses of the form [namespace/]<type>/<name>, where type is one of pod, deployment, daemonset, labelSelector, fieldSelector. If strings.Split(addr, \"/\") yields fewer than 2 segments, the address doesn't follow the scheme and the function panics with the full list of allowed forms.","triggerScenarios":"Calling NewListener with a k8s address lacking the type/name path — e.g. 'my-namespace', 'default/', '', or passing a plain pod name without the 'pod/' prefix.","commonSituations":"Users passing just a pod name assuming the library will infer the type; config strings missing the second '/'; empty env/config value routed to the k8s handler.","solutions":["Use the full scheme: e.g. 'default/pod/my-pod', 'kube-system/daemonset/my-ds', 'ns/labelSelector/app=web'.","Include the namespace prefix if needed: '[namespace/]' is optional but the '<type>/<name>' part is mandatory.","Validate the address (at least one '/' and a known type token) before constructing the listener.","Handle unknown/short addresses by returning an error rather than panicking."],"exampleFix":"// before\nNewListener(\"my-pod\")            // panics\n// after\nNewListener(\"default/pod/my-pod\")","handlingStrategy":"validation","validationCode":"func validK8sAddr(addr string) bool {\n\tparts := strings.Split(addr, \"/\")\n\tif len(parts) < 2 { return false }\n\tt := parts[0]\n\tfor _, ok := range []string{\"pod\", \"deployment\", \"daemonset\", \"labelSelector\", \"fieldSelector\"} {\n\t\tif t == ok { return true }\n\t}\n\treturn false\n}","typeGuard":null,"tryCatchPattern":"if !validK8sAddr(addr) {\n\treturn fmt.Errorf(\"address %q must be [namespace/]<pod|deployment|daemonset|labelSelector|fieldSelector>/<name>\", addr)\n}\nips := k8sIPs(addr)","preventionTips":["Always include <type>/<name> in k8s addresses","Copy exact examples from the doc comment in capture.go","Validate the scheme before constructing the listener","Support optional namespace only as a prefix, never omit the type"],"tags":["kubernetes","validation","panic","address-scheme","go"],"backgroundTag":"invalid-k8s-address-scheme","analyzedSha":"251e45abd242886bb64ff2b2dc98789556b56330","analyzedAt":"2026-09-02T16:44:11.369Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}