Skip to content

Fails when KUBECONFIG contains multiple colon-separated paths #3534

@permyakovsv

Description

@permyakovsv

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

  1. Set KUBECONFIG to multiple paths: export KUBECONFIG=~/.kube/config:/path/to/second/config
  2. Run any cluster-bound command: kn func list
  3. Observe the ErrInvalidKubeconfig error.

Environment

  • kn func version: v0.48.3
  • OS: macOS 26.4
  • KUBECONFIG value format: multiple colon-separated paths

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions