probelabs/goreplay · error

Not supported k8s scheme. Allowed values: [namespace/]pod/[p

Error message

Not supported k8s scheme. Allowed values: [namespace/]pod/[pod_name], [namespace/]deployment/[deployment_name], [namespace/]daemonset/[daemonset_name], [namespace/]label/[label-name]/[label-value]

What it means

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.

Source

Thrown at internal/capture/capture.go:309

//	[namespace/]daemonset/[daemonset_name]
//	[namespace/]labelSelector/[selector]
//	[namespace/]fieldSelector/[selector]
func k8sIPs(addr string) []string {
	config, err := rest.InClusterConfig()
	if err != nil {
		panic(err.Error())
	}

	// creates the clientset
	clientset, err := kubernetes.NewForConfig(config)
	if err != nil {
		panic(err.Error())
	}

	sections := strings.Split(addr, "/")

	if len(sections) < 2 {
		panic("Not supported k8s scheme. Allowed values: [namespace/]pod/[pod_name], [namespace/]deployment/[deployment_name], [namespace/]daemonset/[daemonset_name], [namespace/]label/[label-name]/[label-value]")
	}

	// If no namespace passed, assume it is ALL
	switch sections[0] {
	case "pod", "deployment", "daemonset", "labelSelector", "fieldSelector":
		sections = append([]string{""}, sections...)
	}

	namespace, selectorType, selectorValue := sections[0], sections[1], sections[2]

	labelSelector := ""
	fieldSelector := ""

	switch selectorType {
	case "pod":
		fieldSelector = "metadata.name=" + selectorValue
	case "deployment":
		labelSelector = "app=" + selectorValue

View on GitHub (pinned to 251e45abd2)

Solutions

  1. Use the full scheme: e.g. 'default/pod/my-pod', 'kube-system/daemonset/my-ds', 'ns/labelSelector/app=web'.
  2. Include the namespace prefix if needed: '[namespace/]' is optional but the '<type>/<name>' part is mandatory.
  3. Validate the address (at least one '/' and a known type token) before constructing the listener.
  4. Handle unknown/short addresses by returning an error rather than panicking.

Example fix

// before
NewListener("my-pod")            // panics
// after
NewListener("default/pod/my-pod")
Defensive patterns

Strategy: validation

Validate before calling

func validK8sAddr(addr string) bool {
	parts := strings.Split(addr, "/")
	if len(parts) < 2 { return false }
	t := parts[0]
	for _, ok := range []string{"pod", "deployment", "daemonset", "labelSelector", "fieldSelector"} {
		if t == ok { return true }
	}
	return false
}

Try / catch

if !validK8sAddr(addr) {
	return fmt.Errorf("address %q must be [namespace/]<pod|deployment|daemonset|labelSelector|fieldSelector>/<name>", addr)
}
ips := k8sIPs(addr)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of probelabs/goreplay@251e45abd2 (2026-09-02). Data as JSON: /api/errors/ec8c46b170e0dd12. Report an issue: GitHub.