vxcontrol/pentagi · error

path is required

Error message

path is required

What it means

SanitizeContainerCachePath validates a container-side path before it is used in the flow-files cache. It rejects a containerPath that is empty or contains only whitespace, returning 'path is required' because there is nothing to sanitize or store. The function requires a non-empty relative path naming at least one real component.

Source

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

	return absPath, nil
}

func SanitizeFileName(fileName string) (string, error) {
	trimmedName := strings.TrimSpace(fileName)
	if trimmedName == "" {
		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

View on GitHub (pinned to ea665308ba)

Solutions

  1. Provide a non-empty, non-whitespace relative path as the containerPath argument (e.g. "/tmp/report.pdf" or "logs/app.log").
  2. Trim/default the value at the call site before invoking SanitizeContainerCachePath, and skip entries whose trimmed value is empty.
  3. Log the upstream source of the path (tool call arguments, API request body) and fix whatever produced the empty value.

Example fix

// before
sanitized, err := flowfiles.SanitizeContainerCachePath(req.ContainerPath)
// after
if strings.TrimSpace(req.ContainerPath) == "" {
    return fmt.Errorf("container path is required for pull")
}
sanitized, err := flowfiles.SanitizeContainerCachePath(req.ContainerPath)
Defensive patterns

Strategy: validation

Validate before calling

func requireContainerPath(p string) error {
    if strings.TrimSpace(p) == "" {
        return errors.New("container path must be a non-empty string")
    }
    return nil
}

Type guard

func hasContainerPath(p string) bool {
    return strings.TrimSpace(p) != ""
}

Try / catch

if err != nil {
    if err.Error() == "path is required" {
        return fmt.Errorf("caller must supply a container path: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling flowfiles.SanitizeContainerCachePath("") or with a whitespace-only string such as " ", typically when the caller received an empty path from an LLM tool call argument, a JSON field that was never set, or a container command output that was empty.

Common situations: An agent tool call (e.g. pull_flow_files) passes an unset path argument; a GraphQL/REST client omits the path field; a script building the pull request reads an empty environment variable or empty file listing entry.

Related errors


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