larksuite/cli · error
local input path contains a reserved Windows path component
Error message
local input path contains a reserved Windows path component %q
What it means
Each non-dot path component must pass filepath.IsLocal on Windows; reserved names (CON, PRN, AUX, NUL, COM1..9, LPT1..9) and components with reserved characteristics are rejected. This prevents DOS-device name pitfalls where opening CON or NUL has side effects or silently deviates from the intended file.
Source
Thrown at internal/vfs/localfileio/path_local_windows.go:52
return nil
}
func validateLocalInputPlatform(path string) error {
if isWindowsNonLocalNamespace(path) {
return fmt.Errorf("local input path must not use a Windows network or device namespace")
}
cleaned := filepath.Clean(path)
volume := filepath.VolumeName(cleaned)
remainder := strings.TrimLeft(cleaned[len(volume):], `\/`)
for _, component := range strings.FieldsFunc(remainder, func(r rune) bool {
return r == '\\' || r == '/'
}) {
if component == "." || component == ".." {
continue
}
if !filepath.IsLocal(component) {
return fmt.Errorf("local input path contains a reserved Windows path component %q", component)
}
}
return nil
}
View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Rename the file so no component is a reserved device name (e.g. aux.go -> aux-file.go)
- On a Linux/macOS host this check never fires; ensure you are addressing the file on the intended OS
- Escape nothing — Windows has no escape for reserved names; the file itself must be renamed
Example fix
// before runtime.FileIO().Read(`C:\out\aux`) // after runtime.FileIO().Read(`C:\out\aux-data`)
Defensive patterns
Strategy: validation
Validate before calling
func hasReservedComponent(p string) bool {
for _, c := range strings.FieldsFunc(filepath.Clean(p), func(r rune) bool { return r == '\\' || r == '/' }) {
if c == "." || c == ".." { continue }
if !filepath.IsLocal(c) { return true }
}
return false
} Type guard
func allComponentsLocal(p string) bool {
for _, c := range strings.Split(p, `\`) {
if c != "" && c != "." && c != ".." && !filepath.IsLocal(c) { return false }
}
return true
} Prevention
- Avoid creating files named after DOS devices (CON, NUL, AUX, COM1-9, LPT1-9), especially from Linux tooling that will later be read on Windows
- Sanitize filenames from external sources before saving them
- Run filepath.IsLocal on user-supplied components before building paths
When it happens
Trigger: A path containing a component like CON, NUL, COM1, or a component that filepath.IsLocal deems non-local (e.g. reserved device names with extensions such as notes.txt: not this error, but aux.c works) passed to a local input FileIO operation.
Common situations: Files literally named 'aux' or 'con' created by non-Windows tooling (legal on Linux, reserved on Windows) being referenced on a Windows host.
Related errors
- %s: cannot stat %q: %w
- cannot stat opened file: %w
- file changed between validation and open
- not a regular file (directories, devices, FIFOs, and sockets
- cannot inspect opened file links: %w
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/822f22f551a31ca1.
Report an issue: GitHub.