{"record":{"id":"fc61d691cb1d2ce8","repo":"apache/hadoop","slug":"unsupported-name-has-scheme-but-relative-path-par","errorCode":null,"errorMessage":"Unsupported name: has scheme but relative path-part","messagePattern":"Unsupported name: has scheme but relative path-part","errorType":"exception","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java","lineNumber":87,"sourceCode":"   *  Pre-compiled regular expressions to detect path formats.\n   */\n  private static final Pattern HAS_DRIVE_LETTER_SPECIFIER =\n      Pattern.compile(\"^/?[a-zA-Z]:\");\n\n  /** Pre-compiled regular expressions to detect duplicated slashes. */\n  private static final Pattern SLASHES = Pattern.compile(\"/+\");\n\n  private static final long serialVersionUID = 0xad00f;\n\n  private URI uri; // a hierarchical uri\n\n  /**\n   * Test whether this Path uses a scheme and is relative.\n   * Pathnames with scheme and relative path are illegal.\n   */\n  void checkNotSchemeWithRelative() {\n    if (toUri().isAbsolute() && !isUriPathAbsolute()) {\n      throw new HadoopIllegalArgumentException(\n          \"Unsupported name: has scheme but relative path-part\");\n    }\n  }\n\n  void checkNotRelative() {\n    if (!isAbsolute() && toUri().getScheme() == null) {\n      throw new HadoopIllegalArgumentException(\"Path is relative\");\n    }\n  }\n\n  /**\n   * Return a version of the given Path without the scheme information.\n   *\n   * @param path the source Path\n   * @return a copy of this Path without the scheme information\n   */\n  public static Path getPathWithoutSchemeAndAuthority(Path path) {\n    // This code depends on Path.toString() to remove the leading slash before","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java#L69-L105","documentation":"Path.checkNotSchemeWithRelative() enforces that a URI-carrying Path never has a relative path part: toUri().isAbsolute() (a scheme is present) while the path part does not start with '/' is illegal — e.g. 'file:data/x'. FileSystem and FileContext invoke it during path verification (FileSystem.java:430, FileContext.java:327) and on rename src/dst (FileContext.java:2213), throwing HadoopIllegalArgumentException.","triggerScenarios":"new Path(\"file:relative/path\") or an equivalent scheme-plus-relative string, then any FileSystem/FileContext call on it (verifyPath rejects it). Also concatenating 'scheme:' with a relative segment instead of using Path constructors that qualify properly.","commonSituations":"Hand-built path strings missing '/' after the scheme, URIs parsed from properties like 's3a:bucket/key' (missing '//'), string concatenation of scheme + relative path in ingestion code.","solutions":["Use fully-qualified absolute forms: 'file:///data/x' or 'scheme:///abs/path'","Build paths programmatically: new Path(new URI(scheme, authority, \"/abs/path\", null)) or qualify relative paths before attaching a scheme","Validate with a predicate (toUri().isAbsolute() && !isUriPathAbsolute()) and reject/repair input before FS calls"],"exampleFix":"// before\nPath p = new Path(\"file:data/x\");        // scheme but relative path-part\n// after\nPath p = new Path(\"file:///data/x\");    // absolute path part after the scheme","handlingStrategy":"validation","validationCode":"Path p = new Path(raw);\nif (p.toUri().isAbsolute() && !p.isUriPathAbsolute()) {\n  throw new IllegalArgumentException(\"scheme requires absolute path part: \" + raw);\n}","typeGuard":"static boolean isSchemeWithRelativePath(Path p) {\n  return p.toUri().isAbsolute() && !p.isUriPathAbsolute();\n}","tryCatchPattern":"try {\n  fs.getFileStatus(p);\n} catch (HadoopIllegalArgumentException e) {\n  /* scheme+relative path: rebuild as scheme:///abs and retry once */\n}","preventionTips":["Always write scheme:///absolute/path (or scheme://authority/path)","Build qualified paths via Path/URI constructors, not string concatenation","Reject input lacking a leading slash after the scheme at parse time"],"tags":["path","uri","scheme","invalid-path","hadoop"],"backgroundTag":"malformed-path-uri","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}