kubernetes/kops · warning
KubernetesPath::Hash not supported
Error message
KubernetesPath::Hash not supported
What it means
KubernetesPath represents a path inside the k8s API (e.g. via a ConfigMap-backed VFS), which stores opaque string objects. The VFS layer cannot compute a content hash for such paths, so Hash() unconditionally returns this error for every hash algorithm.
Source
Thrown at util/pkg/vfs/k8sfs.go:133
func (p *KubernetesPath) ReadDir() ([]Path, error) {
return nil, fmt.Errorf("KubernetesPath::ReadDir not supported")
}
func (p *KubernetesPath) ReadTree(ctx context.Context) ([]Path, error) {
return nil, fmt.Errorf("KubernetesPath::ReadTree not supported")
}
func (p *KubernetesPath) Base() string {
return path.Base(p.key)
}
func (p *KubernetesPath) PreferredHash() (*hashing.Hash, error) {
return p.Hash(hashing.HashAlgorithmMD5)
}
func (p *KubernetesPath) Hash(a hashing.HashAlgorithm) (*hashing.Hash, error) {
return nil, fmt.Errorf("KubernetesPath::Hash not supported")
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Avoid hashing KubernetesPath objects; check the concrete path type before calling Hash/PreferredHash and skip or handle unsupported backends
- If you need content identity for k8s-backed data, read the file contents (ReadFile) and hash the bytes yourself
- Report/fix upstream: implement Hash or change PreferredHash to return a sentinel like vfs.ErrHashNotSupported so callers can branch
Example fix
// before
h, err := path.PreferredHash() // fails for k8s-backed paths
// after
if _, ok := path.(*vfs.KubernetesPath); ok {
data, err := path.ReadFile(ctx)
h := hashing.HashAlgorithmMD5.Hash(data)
} else {
h, err = path.PreferredHash()
} Defensive patterns
Strategy: type-guard
Validate before calling
func canHash(p vfs.Path) bool { _, ok := p.(*vfs.KubernetesPath); return !ok } Type guard
func isKubernetesPath(p vfs.Path) (*vfs.KubernetesPath, bool) { kp, ok := p.(*vfs.KubernetesPath); return kp, ok } Try / catch
h, err := p.PreferredHash()
if err != nil {
if _, ok := p.(*vfs.KubernetesPath); ok { /* fall back to hashing ReadFile bytes */ }
return err
} Prevention
- Type-check the vfs.Path concrete type before calling Hash/PreferredHash
- Hash ReadFile bytes for k8s-backed paths instead of relying on VFS hashing
- Treat Hash as an optional capability of the Path interface
When it happens
Trigger: Any call to KubernetesPath.Hash() — including the common indirect path where vfs path hashing is requested via PreferredHash(), which delegates to Hash(hashing.HashAlgorithmMD5).
Common situations: Code that hashes paths generically (e.g. comparing cluster spec files, caching by content hash) when the vfs path happens to be backed by the Kubernetes API server rather than S3/GCS/local storage.
Related errors
- method ConfigBaseFor not supported in server-side client
- server-side client does not support MirrorTo
- invalid kubernetes vfs path: %q
- ReadOnlyError
- error adding needs-update label: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/cbb9d96d8cec6916.
Report an issue: GitHub.