AlistGo/alist · warning
invalid input file path: %w
Error message
invalid input file path: %w
What it means
Thrown by resizeImageToBufferWithFFmpegGo when sanitizeFilePath rejects the path of an image about to be resized for a thumbnail. sanitizeFilePath enforces four rules: the path must be absolute, must not contain shell metacharacters (;;&|`$<>!\n\r\x00), must be stat-able by the process, and must be a regular file. The wrapped error names which rule failed ('file path must be absolute', 'file path contains invalid characters', 'file path is not accessible', 'path is not a regular file').
Source
Thrown at drivers/local/util.go:69
}
if strings.ContainsAny(cleaned, ";&|`$<>!\n\r\x00") {
return "", fmt.Errorf("file path contains invalid characters: %s", path)
}
info, err := os.Stat(cleaned)
if err != nil {
return "", fmt.Errorf("file path is not accessible: %w", err)
}
if !info.Mode().IsRegular() {
return "", fmt.Errorf("path is not a regular file: %s", cleaned)
}
return cleaned, nil
}
// resizeImageToBufferWithFFmpegGo 使用 ffmpeg-go 调整图片大小并输出到内存缓冲区
func resizeImageToBufferWithFFmpegGo(inputFile string, width int, outputFormat string /* e.g., "image2pipe", "png_pipe", "mjpeg" */) (*bytes.Buffer, error) {
sanitized, err := sanitizeFilePath(inputFile)
if err != nil {
return nil, fmt.Errorf("invalid input file path: %w", err)
}
inputFile = sanitized
outBuffer := bytes.NewBuffer(nil)
// Determine codec based on desired output format for piping
// For generic image piping, 'image2' is often used with -f image2pipe
// For specific formats to buffer, you might specify the codec directly
var vcodec string
switch outputFormat {
case "png_pipe": // if you want to ensure PNG format in buffer
vcodec = "png"
case "mjpeg": // if you want to ensure JPEG format in buffer
vcodec = "mjpeg"
// default or "image2pipe" could leave codec choice more to ffmpeg or require -c:v later
}
outputArgs := ffmpeg.KwArgs{View on GitHub (pinned to 843d9dc814)
Solutions
- Check the wrapped error message to identify which sanitizeFilePath rule failed
- If the path is relative, ensure the local driver's root and the object's GetPath() produce absolute paths
- Rename files containing ; & | ` $ < > ! or newlines, or relax the metacharacter check if you trust the input (ffmpeg-go does not use a shell)
- Verify the file still exists and is readable: stat <path> as the same user running the process
Example fix
// before: relative or metachar path passed through
imgBuf, err := resizeImageToBufferWithFFmpegGo(file.GetPath(), d.thumbPixel, "image2pipe")
// after: resolve to an absolute, cleaned path first and skip files known to be problematic
fullPath := file.GetPath()
if !filepath.IsAbs(fullPath) {
fullPath = filepath.Join(d.RootFolderPath, fullPath)
}
imgBuf, err := resizeImageToBufferWithFFmpegGo(fullPath, d.thumbPixel, "image2pipe")
if err != nil {
// fall back to no thumbnail rather than failing the listing
return nil, nil, nil
} Defensive patterns
Strategy: validation
Validate before calling
func validThumbPath(path string) bool {
abs, err := filepath.Abs(path)
if err != nil {
return false
}
info, err := os.Stat(abs)
return err == nil && info.Mode().IsRegular()
} Try / catch
In Go: imgBuf, err := resizeImageToBufferWithFFmpegGo(path, w, "image2pipe"); if err != nil { log thumbnail failure and degrade to a listing without thumbnails — never propagate to the caller of getThumb } Prevention
- Ensure local driver object paths are always absolute before thumbnail work
- Treat thumbnail generation as best-effort: on error return nil thumb, not an error
- Avoid filenames with shell metacharacters, or relax the sanitizer knowing ffmpeg-go passes argv directly
When it happens
Trigger: Calling getThumb on a local driver with useFFmpeg=true where the object's path is relative, contains a character like ';' or '$' or a newline in the filename, points to a symlink target that no longer exists, or points to a directory/fifo/device instead of a regular file.
Common situations: Filenames with shell metacharacters (e.g. 'photo;$1.png'), files deleted between directory listing and thumbnail request, permission-restricted mounts, or symlinked media directories on Windows volumes where ModeIrregular is set.
Related errors
- invalid video path: %w
- ffmpeg-go failed to resize image %s to buffer: %w
- ffmpeg-go produced empty buffer for %s
- failed to open image: %w
- failed to decode image: %w
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/d194900e41c221fa.
Report an issue: GitHub.