{"record":{"id":"6efe963ed49a8328","repo":"apache/hadoop","slug":"path-without-scheme-with-non-null-authority-path","errorCode":null,"errorMessage":"Path without scheme with non-null authority:{path}","messagePattern":"Path without scheme with non-null authority:(.+?)","errorType":"validation","errorClass":"InvalidPathException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java","lineNumber":381,"sourceCode":"   * If the path is fully qualified URI, then its scheme and authority\n   * matches that of this file system. Otherwise the path must be \n   * slash-relative name.\n   * @param path the path.\n   * @throws InvalidPathException if the path is invalid\n   */\n  public void checkPath(Path path) {\n    URI uri = path.toUri();\n    String thatScheme = uri.getScheme();\n    String thatAuthority = uri.getAuthority();\n    if (thatScheme == null) {\n      if (thatAuthority == null) {\n        if (path.isUriPathAbsolute()) {\n          return;\n        }\n        throw new InvalidPathException(\"relative paths not allowed:\" + \n            path);\n      } else {\n        throw new InvalidPathException(\n            \"Path without scheme with non-null authority:\" + path);\n      }\n    }\n    String thisScheme = this.getUri().getScheme();\n    String thisHost = this.getUri().getHost();\n    String thatHost = uri.getHost();\n    \n    // Schemes and hosts must match.\n    // Allow for null Authority for file:///\n    if (!thisScheme.equalsIgnoreCase(thatScheme) ||\n       (thisHost != null && \n            !thisHost.equalsIgnoreCase(thatHost)) ||\n       (thisHost == null && thatHost != null)) {\n      throw new InvalidPathException(\"Wrong FS: \" + path + \", expected: \"\n          + this.getUri());\n    }\n    \n    // Ports must match, unless this FS instance is using the default port, in","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java#L363-L399","documentation":"AbstractFileSystem.checkPath rejects a Path whose URI has an authority but no scheme, e.g. the string \"//nn:8020/data\" which parses to authority \"nn:8020\" with scheme null. No AbstractFileSystem instance can match such a path, because matching starts from the scheme, so it fails fast with InvalidPathException.","triggerScenarios":"new Path(\"//host/share/file\") or new Path(\"//ns1/data\") (leading double slash yields an authority with no scheme); paths deserialized or string-processed in a way that stripped the scheme but kept \"//host:port/\"; concatenating an authority into a path string without the scheme prefix.","commonSituations":"Splitting/joining URI strings and losing the \"hdfs:\" prefix; copying authority-bearing path strings between configs; hand-built path strings that start with \"//\" to denote servers (SMB-style habits).","solutions":["Include the scheme: new Path(\"hdfs://nn:8020/data\")","If the target is local, drop the authority instead: new Path(\"/data\") or new Path(\"file:///data\")","Audit string manipulation that builds paths and always carry scheme://authority/path together"],"exampleFix":"// before\nPath p = new Path(\"//nn1:8020/data/x\"); // Path without scheme with non-null authority\n\n// after\nPath p = new Path(\"hdfs://nn1:8020/data/x\");","handlingStrategy":"validation","validationCode":"URI u = p.toUri();\nif (u.getScheme() == null && u.getAuthority() != null) {\n  throw new IllegalArgumentException(\"Path needs a scheme (did one get stripped?): \" + p);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat paths as opaque URIs; never substring-manipulate them","When serializing paths, store path.toString() (the full URI) rather than the path part","Watch for strings starting with \"//\" — they parse as authority-without-scheme"],"tags":["hadoop","uri","path","scheme","validation"],"backgroundTag":"uri-authority-without-scheme","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}