vxcontrol/pentagi · error
invalid file name
Error message
invalid file name
What it means
validatePathComponent rejects a single name that is ".", "..", "/", or empty after trimming, returning 'invalid file name'. Called directly by SanitizeFileName (a bare "." or ".." filename) and per-segment by SanitizeContainerCachePath.
Source
Thrown at backend/pkg/flowfiles/files.go:160
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")
}
if len(cleanName) > MaxFileNameLength {
return "", fmt.Errorf("file name is too long")
}
for _, r := range cleanName {
if r < 0x20 || r == 0x7f {
return "", fmt.Errorf("file name contains control characters")
}
switch r {
case '/', '\\', ':', '*', '?', '"', '<', '>', '|':
return "", fmt.Errorf("file name contains unsupported characters")
}
}
return cleanName, nil
}
func NewFile(info os.FileInfo, sourceDir string) File {View on GitHub (pinned to ea665308ba)
Solutions
- Supply an actual file name with at least one real character (not '.', '..', '/', or whitespace).
- Strip '.'/'..' segments client-side before sending the path.
- If the caller only has a directory, pass a directory-aware API path rather than using SanitizeFileName on a '.' placeholder.
Example fix
// before
name, err := flowfiles.SanitizeFileName("..")
// after
name, err := flowfiles.SanitizeFileName("report.pdf") Defensive patterns
Strategy: validation
Validate before calling
func isRealFileName(s string) bool {
t := strings.TrimSpace(s)
return t != "" && t != "." && t != ".." && t != "/"
} Type guard
func isRealFileName(s string) bool {
switch strings.TrimSpace(s) {
case "", ".", "..", "/":
return false
}
return true
} Try / catch
if err != nil {
if err.Error() == "invalid file name" {
return fmt.Errorf("%q is not a usable file name", fileName)
}
return err
} Prevention
- Reject '.', '..', and empty names at the input boundary.
- Never use '.' as a placeholder for 'current directory' in file APIs.
- Trim whitespace before validation.
When it happens
Trigger: SanitizeFileName(".") or SanitizeFileName(".."); SanitizeContainerCachePath with a segment that is ".", "..", "/" or trims to empty (e.g. "logs/ /x"); tar/zip extraction names whose base is '.'.
Common situations: Upload requests whose multipart filename is '.'; agent tool calls passing '.' as the file name meaning 'current directory'; paths containing double slashes with whitespace between them; hidden traversal attempts like 'a/../b'.
Related errors
- file name contains control characters
- file name contains unsupported characters
- path is required
- invalid path component '%s': %w
- file name is too long
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/8da37ff9686b39ad.
Report an issue: GitHub.