-
Notifications
You must be signed in to change notification settings - Fork 177
Fails when KUBECONFIG contains multiple colon-separated paths #3534
Description
kn func fails when KUBECONFIG contains multiple colon-separated paths
Describe the bug
kn func commands that require cluster access (e.g., deploy, list, invoke) fail with an ErrInvalidKubeconfig error when the KUBECONFIG environment variable is set to a colon-separated list of paths — which is standard Kubernetes behavior supported by kubectl and client-go.
Expected behavior
kn func should accept a KUBECONFIG value with multiple colon-separated paths (e.g., ~/.kube/config:/other/kubeconfig) the same way kubectl and other Kubernetes tooling does.
Actual behavior
The command fails immediately with an error like:
Error: invalid kubeconfig: kubeconfig file does not exist at path: /home/user/.kube/config:/other/kubeconfig
Possible root cause
validateKubeconfigFile() in pkg/knative/client.go reads the KUBECONFIG env var and passes the entire string directly to os.Stat(), treating it as a single file path:
func validateKubeconfigFile() error {
kubeconfigPath := os.Getenv("KUBECONFIG")
if kubeconfigPath == "" {
return nil
}
if _, err := os.Stat(kubeconfigPath); os.IsNotExist(err) {
return fmt.Errorf("%w: kubeconfig file does not exist at path: %s", fn.ErrInvalidKubeconfig, kubeconfigPath)
}
return nil
}When KUBECONFIG=/path/a:/path/b, os.Stat("/path/a:/path/b") fails because /path/a:/path/b is not a valid single path.
Steps to reproduce
- Set
KUBECONFIGto multiple paths:export KUBECONFIG=~/.kube/config:/path/to/second/config - Run any cluster-bound command:
kn func list - Observe the
ErrInvalidKubeconfigerror.
Environment
kn funcversion: v0.48.3- OS: macOS 26.4
KUBECONFIGvalue format: multiple colon-separated paths