{"record":{"id":"a48603ef2dd58b7d","repo":"denoland/deno","slug":"err-invalid-arg-value-a48603","errorCode":"ERR_INVALID_ARG_VALUE","errorMessage":"The argument 'filepath' Missing UNC resource path. Received ${filepath}","messagePattern":"The argument 'filepath' Missing UNC resource path\\. Received (.+?)","errorType":"error_code","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/url.ts","lineNumber":1639,"sourceCode":"    isWin && StringPrototypeStartsWith(filepath, \"\\\\\\\\?\\\\\") &&\n    !StringPrototypeStartsWith(filepath, \"\\\\\\\\?\\\\UNC\\\\\")\n  ) {\n    const stripped = StringPrototypeSlice(filepath, 4);\n    outURL.pathname = encodePathChars(stripped, { windows });\n    return outURL;\n  }\n  if (isWin && StringPrototypeStartsWith(filepath, \"\\\\\\\\\")) {\n    // UNC path format: \\\\server\\share\\resource\n    // Extended UNC path format: \\\\?\\UNC\\server\\share\\resource\n    const isExtendedUNC = StringPrototypeStartsWith(filepath, \"\\\\\\\\?\\\\UNC\\\\\");\n    const prefixLength = isExtendedUNC ? 8 : 2;\n    const hostnameEndIndex = StringPrototypeIndexOf(\n      filepath,\n      \"\\\\\",\n      prefixLength,\n    );\n    if (hostnameEndIndex === -1) {\n      throw new ERR_INVALID_ARG_VALUE(\n        \"filepath\",\n        filepath,\n        \"Missing UNC resource path\",\n      );\n    }\n    if (hostnameEndIndex === prefixLength) {\n      throw new ERR_INVALID_ARG_VALUE(\n        \"filepath\",\n        filepath,\n        \"Empty UNC servername\",\n      );\n    }\n    const hostname = StringPrototypeSlice(\n      filepath,\n      prefixLength,\n      hostnameEndIndex,\n    );\n    const rest = StringPrototypeSlice(filepath, hostnameEndIndex + 1);","sourceCodeStart":1621,"sourceCodeEnd":1657,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/url.ts#L1621-L1657","documentation":"Thrown by url.pathToFileURL() in Deno's node:url polyfill when filepath looks like a Windows UNC path (starts with \\\\ or \\\\?\\UNC\\) but has no backslash after the server component, so the share/resource part is missing. Node's file URL scheme requires at least \\\\server\\share, so conversion is refused. The check only runs under Windows path semantics (Windows host or options.windows === true).","triggerScenarios":"url.pathToFileURL('\\\\server') or url.pathToFileURL('\\\\?\\UNC\\server') on Windows or with { windows: true } — any input where indexOf('\\\\', prefixLength) is -1 (prefixLength 2 for \\\\, 8 for \\\\?\\UNC\\).","commonSituations":"Hand-typed or config-assembled SMB paths that omit the share name ('\\\\fileserver' instead of '\\\\fileserver\\share'); path-building code that treats the share segment as optional; sanitizers that strip backslashes and eat the separator after the server; cross-platform tests forcing windows: true with truncated UNC fixtures.","solutions":["Include the share component: use at least '\\\\server\\share' ('\\\\server\\share\\file.txt' for a file).","Validate user/config-supplied UNC paths before conversion: after the \\\\ (or \\\\?\\UNC\\) prefix there must be a non-empty server followed by another backslash.","For extended UNC keep the full form \\\\?\\UNC\\server\\share\\... — a backslash must follow the server name.","If a UNC path was not intended, drop the leading \\\\ or pass a drive path like C:\\data instead."],"exampleFix":"// before — server only, no share\nurl.pathToFileURL(\"\\\\\\\\nas\"); // throws ERR_INVALID_ARG_VALUE\n\n// after — minimum valid UNC form\nurl.pathToFileURL(\"\\\\\\\\nas\\\\media\"); // -> file://nas/media/","handlingStrategy":"validation","validationCode":"function hasUncShare(p) {\n  if (!p.startsWith(\"\\\\\\\\\")) return true; // not a UNC path\n  const prefix = p.startsWith(\"\\\\\\\\?\\\\UNC\\\\\") ? 8 : 2;\n  const i = p.indexOf(\"\\\\\", prefix);\n  return i > prefix; // \\\\server\\share at minimum\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat \\\\ and \\\\?\\UNC\\ inputs as structured data: parse server and share segments before building URLs.","Keep UNC fixtures in cross-platform tests: one valid (\\\\server\\share\\file) plus malformed variants to catch regressions.","Document for users/config authors that Windows UNC paths must include the share name."],"tags":["windows","unc","file-url","path-to-file-url","err-invalid-arg-value"],"backgroundTag":"unc-path-validation","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}