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

  1. Rename the file so no component is a reserved device name (e.g. aux.go -> aux-file.go)
  2. On a Linux/macOS host this check never fires; ensure you are addressing the file on the intended OS
  3. 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

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


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/822f22f551a31ca1. Report an issue: GitHub.