AlistGo/alist · warning
invalid video path: %w
Error message
invalid video path: %w
What it means
GetSnapshot rejects the video path via the same sanitizeFilePath gate used for images: path must be absolute, free of shell metacharacters (;;&|`$<>!\n\r\x00), stat-able, and a regular file. The wrapped error names the failing rule. This runs before ffprobe, so it fires only on path problems, not on media problems.
Source
Thrown at drivers/local/util.go:156
// outputFormat := imaging.PNG
// encodeOptions := []imaging.EncodeOption{}
err = imaging.Encode(&buf, thumbImg, outputFormat, encodeOptions...)
if err != nil {
return nil, fmt.Errorf("failed to encode thumbnail: %w", err)
}
thumbImg = nil
return &buf, nil
}
// Get the snapshot of the video
func (d *Local) GetSnapshot(videoPath string) (imgData *bytes.Buffer, err error) {
sanitized, err := sanitizeFilePath(videoPath)
if err != nil {
return nil, fmt.Errorf("invalid video path: %w", err)
}
videoPath = sanitized
// Run ffprobe to get the video duration
jsonOutput, err := ffmpeg.Probe(videoPath)
if err != nil {
return nil, err
}
// get format.duration from the json string
type probeFormat struct {
Duration string `json:"duration"`
}
type probeData struct {
Format probeFormat `json:"format"`
}
var probe probeData
err = json.Unmarshal([]byte(jsonOutput), &probe)
if err != nil {View on GitHub (pinned to 843d9dc814)
Solutions
- Read the wrapped message to see which rule failed
- Rename files containing metacharacters, or adjust sanitizeFilePath since ffmpeg-go spawns ffmpeg directly (no shell) and only NUL/newline truly need rejecting
- Verify the video exists and the process user can stat it
Example fix
// before: every metacharacter rejected, ffmpeg invoked without a shell anyway
if strings.ContainsAny(cleaned, ";&|`$<>!\n\r\x00") {
return "", fmt.Errorf("file path contains invalid characters: %s", path)
}
// after: only reject characters that cannot appear in a single argv element
if strings.ContainsAny(cleaned, "\n\r\x00") {
return "", fmt.Errorf("file path contains invalid characters: %s", path)
} Defensive patterns
Strategy: validation
Validate before calling
if !filepath.IsAbs(videoPath) { return nil, fmt.Errorf("video path must be absolute") }
if info, err := os.Stat(videoPath); err != nil || !info.Mode().IsRegular() { return nil, nil /* skip snapshot */ } Try / catch
In getThumb, wrap GetSnapshot; on error return (nil, nil, err-swigged-thumb) so the listing still renders and the failure is only logged.
Prevention
- Keep video paths absolute from the driver root
- Skip snapshots for files whose names contain newline/NUL instead of failing the whole request
- Remember sanitizeFilePath rejects many legal filenames ($ ; !) — rename media or narrow the character blocklist
When it happens
Trigger: Requesting a thumbnail for a video whose path contains '$' or ';' (very common in scene-release filenames), a video behind a broken symlink, or a video that was deleted after the directory listing was cached.
Common situations: Filenames like 'Movie.2023.1080p;$hadow.mp4' or subtitled releases with '!' in the name; symlinked media libraries; thumbnails requested for entries from a stale cache.
Related errors
- invalid input file path: %w
- ffmpeg-go failed to resize image %s to buffer: %w
- ffmpeg-go produced empty buffer for %s
- failed to open image: %w
- directory separator prohibited
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/048691c71daae8c9.
Report an issue: GitHub.