{"record":{"id":"5ff0381eda724801","repo":"vxcontrol/pentagi","slug":"failed-to-resolve-relative-cache-path-w","errorCode":null,"errorMessage":"failed to resolve relative cache path: %w","messagePattern":"failed to resolve relative cache path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"backend/pkg/flowfiles/files.go","lineNumber":267,"sourceCode":"\t\t\t\treturn filepath.SkipDir\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t\tif entry.Type()&os.ModeSymlink != 0 {\n\t\t\treturn nil\n\t\t}\n\n\t\tinfo, err := entry.Info()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !info.Mode().IsRegular() && !info.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\trel, err := filepath.Rel(dir, entryPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to resolve relative cache path: %w\", err)\n\t\t}\n\t\tfiles = append(files, NewFileWithPath(info, path.Join(sourceDir, filepath.ToSlash(rel))))\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn files, nil\n}\n\nfunc Sort(files []File) {\n\tsort.Slice(files, func(i, j int) bool {\n\t\tif files[i].Path < files[j].Path {\n\t\t\treturn true\n\t\t} else if files[i].Path > files[j].Path {\n\t\t\treturn false\n\t\t} else if files[i].Name < files[j].Name {","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/flowfiles/files.go#L249-L285","documentation":"Inside ListDirEntriesRecursive's filepath.WalkDir callback, filepath.Rel(dir, entryPath) computes each entry's path relative to the walked root. This error wraps a non-nil error from filepath.Rel, which is practically impossible when entryPath comes from walking dir itself — it indicates the walker was invoked with an entryPath outside dir (a corrupted walk state or custom misuse).","triggerScenarios":"ListDirEntriesRecursive (container/ or resources/ cache listing) when the WalkDir callback receives an entryPath that cannot be made relative to dir — essentially only if the walk root and callback disagree, e.g. dir being the empty string or a programmer-supplied root that changed mid-walk.","commonSituations":"Calls with an empty dir argument instead of a valid cache directory (though Lstat usually catches that first); concurrent modification/race in custom forks; a bug where the callback is reused with a different root than dir.","solutions":["Verify the dir argument passed to ListDirEntriesRecursive is a non-empty absolute/relative directory path produced by FlowContainerDir/FlowResourcesDir.","Check for concurrent modification of the walk root; snapshot or serialize directory mutations during listing.","If it persists, file a bug — this indicates an internal invariant violation in the walk, not caller input."],"exampleFix":"// before\nentries, err := flowfiles.ListDirEntriesRecursive(\"\", flowfiles.ContainerDirName)\n// after\nentries, err := flowfiles.ListDirEntriesRecursive(flowfiles.FlowContainerDir(dataDir, flowID), flowfiles.ContainerDirName)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"failed to resolve relative cache path\") {\n        log.Printf(\"walk invariant violated: %v\", err)\n        return fmt.Errorf(\"cache listing failed; retry listing: %w\", err)\n    }\n    return err\n}","preventionTips":["Always pass a real directory from FlowContainerDir/FlowResourcesDir, never \"\" or \".\".","Avoid mutating the cache tree concurrently with listing.","Treat this error as an internal bug; report with the dir argument."],"tags":["go","filesystem","walkdir"],"backgroundTag":"relative-path-resolution-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}