{"record":{"id":"faad51e064b6975b","repo":"vxcontrol/pentagi","slug":"file-name-is-too-long","errorCode":null,"errorMessage":"file name is too long","messagePattern":"file name is too long","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"backend/pkg/flowfiles/files.go","lineNumber":163,"sourceCode":"\tparts := strings.Split(cleanPath, \"/\")\n\tfor i, part := range parts {\n\t\tcleanPart, err := validatePathComponent(part)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"invalid path component '%s': %w\", part, err)\n\t\t}\n\t\tparts[i] = cleanPart\n\t}\n\n\treturn path.Join(parts...), nil\n}\n\nfunc validatePathComponent(component string) (string, error) {\n\tcleanName := strings.TrimSpace(component)\n\tif cleanName == \".\" || cleanName == \"..\" || cleanName == \"/\" || cleanName == \"\" {\n\t\treturn \"\", fmt.Errorf(\"invalid file name\")\n\t}\n\tif len(cleanName) > MaxFileNameLength {\n\t\treturn \"\", fmt.Errorf(\"file name is too long\")\n\t}\n\tfor _, r := range cleanName {\n\t\tif r < 0x20 || r == 0x7f {\n\t\t\treturn \"\", fmt.Errorf(\"file name contains control characters\")\n\t\t}\n\t\tswitch r {\n\t\tcase '/', '\\\\', ':', '*', '?', '\"', '<', '>', '|':\n\t\t\treturn \"\", fmt.Errorf(\"file name contains unsupported characters\")\n\t\t}\n\t}\n\n\treturn cleanName, nil\n}\n\nfunc NewFile(info os.FileInfo, sourceDir string) File {\n\treturn NewFileWithPath(info, path.Join(sourceDir, info.Name()))\n}\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/flowfiles/files.go#L145-L181","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Shorten the offending component to ≤255 bytes (≤255 UTF-8 bytes, counting multibyte characters).","Hash or truncate the long name (keeping the extension) before calling, e.g. name[:100]+md5[:8]+\".ext\".","Pre-check with len(component) > 255 client-side and rename before upload/pull."],"exampleFix":"// before\nname, err := flowfiles.SanitizeFileName(strings.Repeat(\"a\", 300) + \".txt\")\n// after\nlong := strings.Repeat(\"a\", 300) + \".txt\"\nname, err := flowfiles.SanitizeFileName(long[:100] + \"-truncated.txt\")","handlingStrategy":"validation","validationCode":"func fitsInOneComponent(s string) bool {\n    return len(strings.TrimSpace(s)) <= 255 // MaxFileNameLength\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if err.Error() == \"file name is too long\" {\n        return fmt.Errorf(\"name exceeds 255 bytes; truncate or hash it before upload\")\n    }\n    return err\n}","preventionTips":["Check byte length (not rune count) before upload — UTF-8 names count bytes.","Truncate long generated names while preserving the extension.","Keep hashes/timestamp suffixes within the 255-byte budget."],"tags":["go","filename-validation","filename-length"],"backgroundTag":"filename-too-long","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}