{"record":{"id":"fa708a7ca63a634b","repo":"apache/hadoop","slug":"invalid-path-string","errorCode":null,"errorMessage":"Invalid path string ","messagePattern":"Invalid path string ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/PathData.java","lineNumber":523,"sourceCode":"   *    @param pathString Path string supplied by the user.\n   *    @return normalized absolute path string. Returns the input string\n   *            if it is not a Windows absolute path.\n   */\n  private static String normalizeWindowsPath(String pathString)\n  throws IOException\n  {\n    if (!Path.WINDOWS) {\n      return pathString;\n    }\n\n    boolean slashed =\n        ((pathString.length() >= 1) && (pathString.charAt(0) == '/'));\n\n    // Is it a backslash-separated absolute path?\n    if (windowsNonUriAbsolutePath1.matcher(pathString).find()) {\n      // Forward slashes disallowed in a backslash-separated path.\n      if (pathString.indexOf('/') != -1) {\n        throw new IOException(\"Invalid path string \" + pathString);\n      }\n\n      pathString = pathString.replace('\\\\', '/');\n      return \"file:\" + (slashed ? \"\" : \"/\") + pathString;\n    }\n\n    // Is it a forward slash-separated absolute path?\n    if (windowsNonUriAbsolutePath2.matcher(pathString).find()) {\n      return \"file:\" + (slashed ? \"\" : \"/\") + pathString;\n    }\n\n    // Is it a backslash-separated relative file path (no scheme and\n    // no drive-letter specifier)?\n    if ((pathString.indexOf(':') == -1) && (pathString.indexOf('\\\\') != -1)) {\n      pathString = pathString.replace('\\\\', '/');\n    }\n\n    return pathString;","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/PathData.java#L505-L541","documentation":"PathData.normalizePath's Windows branch (PathData.java:523) throws IOException('Invalid path string <path>') when the input matches windowsNonUriAbsolutePath1 (backslash-separated drive-absolute path like D:\\dir) yet contains at least one forward slash. This is the same mixed-separator rule as checkIfSchemeInferredFromPath, applied when normalizing Windows paths to file: URIs for display/comparison.","triggerScenarios":"Any hadoop fs shell path handling that routes through normalizePath on Windows (Path.WINDOWS) with strings like 'D:\\logs/current' — e.g., command output formatting, path comparisons in copy/move target resolution. The throw happens before backslash-to-slash replacement can run.","commonSituations":"Windows clients building paths by concatenating a backslash base with forward-slash relative parts; scripts generated by tools with different separator conventions; paths logged and re-fed into commands after partial normalization.","solutions":["Use exclusively forward slashes on Windows paths: 'D:/logs/current' (matches windowsNonUriAbsolutePath2 and normalizes cleanly)","Pre-normalize inputs: pathString = pathString.replace('\\\\', '/') before passing to shell commands","Pass full URIs ('file:///D:/logs/current') so the Windows inference/normalization path is bypassed"],"exampleFix":"# before\nhadoop fs -ls D:\\logs/2026\\aug  # mixed separators\n# ls: Invalid path string D:\\logs/2026\\aug\n\n# after\nhadoop fs -ls 'D:/logs/2026/aug'","handlingStrategy":"validation","validationCode":"String norm = raw.contains(\":\\\\\") || raw.contains(\"\\\\\") ? raw.replace('\\\\', '/') : raw;\n// pass norm to shell commands / Path construction on Windows","typeGuard":null,"tryCatchPattern":"catch (IOException e) when 'Invalid path string' -> re-issue with uniform '/' separators or a file: URI","preventionTips":["Standardize on '/' separators everywhere in Hadoop tooling","Sanitize externally sourced path strings before use","Prefer file:/// URIs for Windows local paths"],"tags":["windows","path-validation","invalid-path","mixed-separators","pathdata"],"backgroundTag":"invalid-path-format","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}