vxcontrol/pentagi · warning

failed to resolve relative cache path: %w

Error message

failed to resolve relative cache path: %w

What it means

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).

Source

Thrown at backend/pkg/flowfiles/files.go:267

				return filepath.SkipDir
			}
			return nil
		}
		if entry.Type()&os.ModeSymlink != 0 {
			return nil
		}

		info, err := entry.Info()
		if err != nil {
			return err
		}
		if !info.Mode().IsRegular() && !info.IsDir() {
			return nil
		}

		rel, err := filepath.Rel(dir, entryPath)
		if err != nil {
			return fmt.Errorf("failed to resolve relative cache path: %w", err)
		}
		files = append(files, NewFileWithPath(info, path.Join(sourceDir, filepath.ToSlash(rel))))
		return nil
	})
	if err != nil {
		return nil, err
	}

	return files, nil
}

func Sort(files []File) {
	sort.Slice(files, func(i, j int) bool {
		if files[i].Path < files[j].Path {
			return true
		} else if files[i].Path > files[j].Path {
			return false
		} else if files[i].Name < files[j].Name {

View on GitHub (pinned to ea665308ba)

Solutions

  1. Verify the dir argument passed to ListDirEntriesRecursive is a non-empty absolute/relative directory path produced by FlowContainerDir/FlowResourcesDir.
  2. Check for concurrent modification of the walk root; snapshot or serialize directory mutations during listing.
  3. If it persists, file a bug — this indicates an internal invariant violation in the walk, not caller input.

Example fix

// before
entries, err := flowfiles.ListDirEntriesRecursive("", flowfiles.ContainerDirName)
// after
entries, err := flowfiles.ListDirEntriesRecursive(flowfiles.FlowContainerDir(dataDir, flowID), flowfiles.ContainerDirName)
Defensive patterns

Strategy: try-catch

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "failed to resolve relative cache path") {
        log.Printf("walk invariant violated: %v", err)
        return fmt.Errorf("cache listing failed; retry listing: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01). Data as JSON: /api/errors/5ff0381eda724801. Report an issue: GitHub.