vxcontrol/pentagi · error

file name is too long

Error message

file name is too long

What it means

validatePathComponent enforces MaxFileNameLength (255 bytes, matching common filesystem limits) per path component. A component exceeding 255 bytes returns 'file name is too long'. Note the check is on byte length (len), so multibyte UTF-8 names hit the limit sooner.

Source

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

	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 {
	return NewFileWithPath(info, path.Join(sourceDir, info.Name()))
}

View on GitHub (pinned to ea665308ba)

Solutions

  1. Shorten the offending component to ≤255 bytes (≤255 UTF-8 bytes, counting multibyte characters).
  2. Hash or truncate the long name (keeping the extension) before calling, e.g. name[:100]+md5[:8]+".ext".
  3. Pre-check with len(component) > 255 client-side and rename before upload/pull.

Example fix

// before
name, err := flowfiles.SanitizeFileName(strings.Repeat("a", 300) + ".txt")
// after
long := strings.Repeat("a", 300) + ".txt"
name, err := flowfiles.SanitizeFileName(long[:100] + "-truncated.txt")
Defensive patterns

Strategy: validation

Validate before calling

func fitsInOneComponent(s string) bool {
    return len(strings.TrimSpace(s)) <= 255 // MaxFileNameLength
}

Try / catch

if err != nil {
    if err.Error() == "file name is too long" {
        return fmt.Errorf("name exceeds 255 bytes; truncate or hash it before upload")
    }
    return err
}

Prevention

When it happens

Trigger: SanitizeFileName or SanitizeContainerCachePath with a component longer than 255 bytes — e.g. very long generated names, deeply descriptive agent filenames, or names with many multibyte characters.

Common situations: LLM agents producing long descriptive file names; copies of files with appended hashes/timestamps pushing past 255 bytes; non-ASCII names where 255 bytes ≪ 255 characters; uploading files with names near the ext4/NTFS 255-byte limit.

Related errors


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