{"record":{"id":"f231a45b12170b69","repo":"larksuite/cli","slug":"path-must-not-use-a-windows-network-or-device-name","errorCode":null,"errorMessage":"path must not use a Windows network or device namespace","messagePattern":"path must not use a Windows network or device namespace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/vfs/localfileio/path_local_windows.go","lineNumber":20,"sourceCode":"// SPDX-License-Identifier: MIT\n\n//go:build windows\n\npackage localfileio\n\nimport (\n\t\"fmt\"\n\t\"path/filepath\"\n\t\"strings\"\n)\n\n// validatePathPlatform rejects Windows path shapes the policy cannot reason\n// about: network/device namespaces (UNC, \\\\?\\) and NTFS alternate data\n// streams (a colon anywhere past the drive letter would address a hidden\n// stream on an otherwise-allowed file).\nfunc validatePathPlatform(path string) error {\n\tif isWindowsNonLocalNamespace(path) {\n\t\treturn fmt.Errorf(\"path must not use a Windows network or device namespace\")\n\t}\n\tcleaned := filepath.Clean(path)\n\t// A drive-relative path (\"C:foo\") carries a volume but is not absolute: it\n\t// resolves against that drive's own current directory, so the location it\n\t// names is not the one this validation can see. It is also how the stream\n\t// check below would be slipped, since \"C:\" is stripped as the volume and\n\t// the remaining \"foo\" holds no colon.\n\tif filepath.VolumeName(cleaned) != \"\" && !filepath.IsAbs(cleaned) {\n\t\treturn fmt.Errorf(\"path must not be drive-relative; give a full path or a path without a drive letter\")\n\t}\n\tif strings.Contains(cleaned[len(filepath.VolumeName(cleaned)):], \":\") {\n\t\treturn fmt.Errorf(\"path must not address an NTFS alternate data stream\")\n\t}\n\treturn nil\n}\n\nfunc validateLocalInputPlatform(path string) error {\n\tif isWindowsNonLocalNamespace(path) {","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/vfs/localfileio/path_local_windows.go#L2-L38","documentation":"On Windows, `validatePathPlatform` rejects paths that use Windows network or device namespaces — UNC (`\\\\server\\share`), device paths (`\\\\?\\`), or NT-object prefixes (`\\??\\`). The path-safety policy cannot reason about where these open, so they are refused outright. This error is wrapped with the flag name by safePath on the strict tier.","triggerScenarios":"Passing `--file \\\\server\\share\\doc.pdf`, `--output \\\\?\\C:\\dir\\file`, or a forward-slash variant `//server/share` on Windows; also paths copied from Win32 API calls with the extended-length prefix.","commonSituations":"Downloading to or uploading from a network share in an enterprise environment; scripts that copied extended-length paths from `robocopy` output; tooling that emits `\\\\?\\` to bypass MAX_PATH.","solutions":["Map the network share to a drive letter and use a local absolute path (e.g. `net use Z: \\\\server\\share` then `Z:\\dir\\file`).","Copy the file into an allowed local root (cwd, %TEMP%, or the user's files directory) and use that path.","Strip the `\\\\?\\` extended-length prefix, keeping an ordinary absolute path."],"exampleFix":"// before (Windows)\nlark-cli drive upload --file \\\\srv\\share\\report.pdf\n// after\nnet use Z: \\\\srv\\share\nlark-cli drive upload --file Z:\\report.pdf","handlingStrategy":"validation","validationCode":"// Go: reject UNC / device namespace shapes before passing the path\nnormalized := strings.ReplaceAll(p, \"/\", `\\\\`)\nif strings.HasPrefix(normalized, `\\\\`) || strings.HasPrefix(normalized, `\\??\\`) {\n    return fmt.Errorf(\"map the share to a drive letter or use a local path: %q\", p)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use mapped drive letters instead of \\\\server\\share paths.","Strip \\\\?\\ prefixes captured from Win32 tooling output.","Stage files to a local temp directory when the source/destination is a network share."],"tags":["windows","unc-path","path-validation","go"],"backgroundTag":"windows-namespace-path-rejected","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}