vxcontrol/pentagi · error

invalid path

Error message

invalid path

What it means

SanitizeContainerCachePath normalizes backslashes, cleans the path against a virtual root, and rejects the result when it collapses to "." or empty — meaning the input was effectively a root (",/", ".", "/./") with no real component. It returns 'invalid path' to prevent caching or copying the entire filesystem root.

Source

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

		return "", fmt.Errorf("file name is required")
	}

	normalizedName := strings.ReplaceAll(trimmedName, "\\", "/")
	cleanName := path.Base(path.Clean("/" + normalizedName))

	return validatePathComponent(cleanName)
}

func SanitizeContainerCachePath(containerPath string) (string, error) {
	trimmedPath := strings.TrimSpace(containerPath)
	if trimmedPath == "" {
		return "", fmt.Errorf("path is required")
	}

	normalizedPath := strings.ReplaceAll(trimmedPath, "\\", "/")
	cleanPath := strings.TrimPrefix(path.Clean("/"+normalizedPath), "/")
	if cleanPath == "." || cleanPath == "" {
		return "", fmt.Errorf("invalid path")
	}

	parts := strings.Split(cleanPath, "/")
	for i, part := range parts {
		cleanPart, err := validatePathComponent(part)
		if err != nil {
			return "", fmt.Errorf("invalid path component '%s': %w", part, err)
		}
		parts[i] = cleanPart
	}

	return path.Join(parts...), nil
}

func validatePathComponent(component string) (string, error) {
	cleanName := strings.TrimSpace(component)
	if cleanName == "." || cleanName == ".." || cleanName == "/" || cleanName == "" {
		return "", fmt.Errorf("invalid file name")

View on GitHub (pinned to ea665308ba)

Solutions

  1. Pass a specific file or subdirectory path (e.g. "/var/log/app.log"), not a filesystem root.
  2. If 'pull everything' is intended, enumerate candidate paths first and call SanitizeContainerCachePath per entry.
  3. Update the calling agent's prompt/tool schema to require a concrete file path rather than a root.

Example fix

// before
pullFiles(containerPath: "/")
// after
pullFiles(containerPath: "/var/log/app.log")
Defensive patterns

Strategy: validation

Validate before calling

func isConcretePath(p string) bool {
    n := path.Clean("/" + strings.ReplaceAll(strings.TrimSpace(p), "\\", "/"))
    return n != "/" && n != "/."
}

Type guard

func isRootish(p string) bool {
    n := path.Clean("/" + strings.ReplaceAll(strings.TrimSpace(p), "\\", "/"))
    return n == "/" || n == "/."
}

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "invalid path") {
        return fmt.Errorf("refusing root-like container path %q", containerPath)
    }
    return err
}

Prevention

When it happens

Trigger: Calling SanitizeContainerCachePath with ".", "/", "\\", "/.", ".//", or any path that normalizes to the root after path.Clean("/"+p) strips back to the virtual root.

Common situations: An LLM agent answers pull_flow_files with "/" or "." meaning 'everything'; a user drags a folder root into the UI and the client sends the root path; Windows-style paths reduced to a drive root like "C:\" before reaching the sanitizer.

Related errors


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