{"record":{"id":"d05b7e7ef74b1a78","repo":"kubernetes/kops","slug":"error-finding-relative-path-for-q-v","errorCode":null,"errorMessage":"error finding relative path for %q: %v","messagePattern":"error finding relative path for %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"upup/pkg/fi/assetstore.go","lineNumber":337,"sourceCode":"\t\t\treturn fmt.Errorf(\"error renaming extracted temp dir %s -> %s: %v\", extractedTemp, extracted, err)\n\t\t}\n\t}\n\n\tlocalBase := extracted\n\tassetBase := \"\"\n\n\twalker := func(localPath string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error descending into path %q: %v\", localPath, err)\n\t\t}\n\n\t\tif info.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\trelativePath, err := filepath.Rel(localBase, localPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error finding relative path for %q: %v\", localPath, err)\n\t\t}\n\n\t\tassetPath := path.Join(assetBase, relativePath)\n\t\tkey := info.Name()\n\t\tr := NewFileResource(localPath)\n\n\t\tasset := &asset{\n\t\t\tKey:       key,\n\t\t\tAssetPath: assetPath,\n\t\t\tresource:  r,\n\t\t\tsource:    &Source{Parent: archiveSource, ExtractFromArchive: assetPath},\n\t\t}\n\t\tklog.V(2).Infof(\"added asset %q for %q\", asset.Key, asset.resource)\n\t\ta.assets = append(a.assets, asset)\n\n\t\treturn nil\n\t}\n","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/assetstore.go#L319-L355","documentation":"For every regular file found in the extracted tree, addArchive computes its path relative to localBase with filepath.Rel to build the asset key. filepath.Rel fails (an ErrBadPair-style error) only when the two paths cannot be made relative — practically impossible when localPath comes from the same walk — so this indicates an internal invariant violation or a corrupted localBase (e.g. non-absolute/relative mismatch).","triggerScenarios":"filepath.Walk callback in addArchive: filepath.Rel(localBase, localPath) returns error because localBase is not a prefix-compatible base for localPath — only via programming/config error, not from normal user input.","commonSituations":"Effectively never hit by end users; would appear if the extraction root constant changed or path handling was refactored to mix relative and absolute paths.","solutions":["Report as a bug: capture localBase and localPath from the message.","Verify the kOps version and check for related fixed issues in the changelog.","Work around by re-running; this error is deterministic, so escalate to maintainers if reproducible."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import path from \"path\" // sanity-check base/path relationship the way filepath.Rel requires\nfunction canBeRelative(base: string, target: string): boolean {\n  const rBase = path.resolve(base), rTarget = path.resolve(target)\n  return rTarget === rBase || rTarget.startsWith(rBase + path.sep)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await addURLs(urls)\n} catch (e) {\n  if (/error finding relative path for/.test(e.message)) {\n    // internal invariant violation — capture message and report a bug\n    console.error(\"BUG: report with this message:\", e.message)\n  }\n  throw e\n}","preventionTips":["Report this to kOps maintainers with the full message — it is not user-triggerable.","Note the kOps version; check for fixed regressions in path handling.","Keep asset path configuration at defaults unless debugging this family of errors."],"tags":["filesystem","internal","assets"],"backgroundTag":"relative-path-computation-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}