{"record":{"id":"5676fbe4db8417c2","repo":"kubernetes/kops","slug":"path-q-is-not-a-child-of-q","errorCode":null,"errorMessage":"Path %q is not a child of %q","messagePattern":"Path %q is not a child of %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/vfs/vfs.go","lineNumber":109,"sourceCode":"}\n\ntype HasHash interface {\n\t// Returns the hash of the file contents, with the preferred hash algorithm\n\tPreferredHash() (*hashing.Hash, error)\n\n\t// Gets the hash, or nil if the hash cannot be (easily) computed\n\tHash(algorithm hashing.HashAlgorithm) (*hashing.Hash, error)\n}\n\nfunc RelativePath(base Path, child Path) (string, error) {\n\tbasePath := base.Path()\n\tchildPath := child.Path()\n\tif !strings.HasSuffix(basePath, \"/\") {\n\t\tbasePath += \"/\"\n\t}\n\n\tif !strings.HasPrefix(childPath, basePath) {\n\t\treturn \"\", fmt.Errorf(\"Path %q is not a child of %q\", child, base)\n\t}\n\n\trelativePath := childPath[len(basePath):]\n\treturn relativePath, nil\n}\n\nfunc IsClusterReadable(p Path) bool {\n\tif hcr, ok := p.(HasClusterReadable); ok {\n\t\treturn hcr.IsClusterReadable()\n\t}\n\n\tswitch p.(type) {\n\tcase *S3Path, *GSPath, *SwiftPath, *FSPath, *AzureBlobPath:\n\t\treturn true\n\n\tcase *KubernetesPath:\n\t\treturn true\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/vfs/vfs.go#L91-L127","documentation":"Validation guard in RelativePath: the child path's string form does not start with the base path (plus a trailing \"/\"), so the child is not actually located under the base. This fires when callers pass unrelated or sibling paths — e.g. a keyset or cluster-state object whose VFS location escapes the cluster's base directory — and no relative path can be computed.","triggerScenarios":"Thrown at util/pkg/vfs/vfs.go:109 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that both paths come from the same VFS root and the base is a true ancestor of the child","Normalize paths (resolve trailing slashes, canonicalize scheme and host) before comparing","Reject or skip objects outside the expected prefix instead of forcing the computation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}