{"record":{"id":"0743d2481934a9be","repo":"apache/hadoop","slug":"query-component-in-path-not-supported","errorCode":null,"errorMessage":"query component in Path not supported  {}","messagePattern":"query component in Path not supported  (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java","lineNumber":239,"sourceCode":"    //system in the config \n    //so create a underlying uri and \n    //return it\n    if (tmpAuth == null) {\n      //create a path \n      return FileSystem.getDefaultUri(conf);\n    }\n    String authority = rawURI.getAuthority();\n\n    int i = authority.indexOf('-');\n    if (i < 0) {\n      throw new IOException(\"URI: \" + rawURI\n          + \" is an invalid Har URI since '-' not found.\"\n          + \"  Expecting har://<scheme>-<host>/<path>.\");\n    }\n \n    if (rawURI.getQuery() != null) {\n      // query component not allowed\n      throw new IOException(\"query component in Path not supported  \" + rawURI);\n    }\n \n    URI tmp;\n    try {\n      // convert <scheme>-<host> to <scheme>://<host>\n      URI baseUri = new URI(authority.replaceFirst(\"-\", \"://\"));\n \n      tmp = new URI(baseUri.getScheme(), baseUri.getAuthority(),\n            rawURI.getPath(), rawURI.getQuery(), rawURI.getFragment());\n    } catch (URISyntaxException e) {\n      throw new IOException(\"URI: \" + rawURI\n          + \" is an invalid Har URI. Expecting har://<scheme>-<host>/<path>.\");\n    }\n    return tmp;\n  }\n\n  private static String decodeString(String str)\n    throws UnsupportedEncodingException {","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java#L221-L257","documentation":"HarFileSystem.decodeHarURI (HarFileSystem.java:218-254) rejects har:// URIs that carry a query component. A Hadoop Archive address is strictly har://<underlying-scheme>-<host>/<archive-path>/<member>; a '?key=value' suffix has no meaning for archives, so the URI is refused during FileSystem initialization, before the underlying filesystem is even contacted.","triggerScenarios":"Any FileSystem API whose Path URI has a query, e.g. new Path(\"har://hdfs-nn:8020/user/a/data.har/file.txt?ver=1\"). The check rawURI.getQuery() != null fires inside decodeHarURI, so even FileSystem.get(path) or fs.exists(path) fails at initialization time.","commonSituations":"Paths assembled by string concatenation that append HTTP-style parameters; passing a full URL where a har path is expected; a literal '?' in a file name that was not percent-encoded when the Path was built.","solutions":["Remove the query component from the har:// path and pass parameters out-of-band (e.g. via Configuration)","If the '?' is part of an actual file name, percent-encode it as %3F when constructing the Path so URI.getQuery() stays null","Validate paths up front with path.toUri().getQuery() == null before handing them to the FileSystem"],"exampleFix":"// before\nPath p = new Path(\"har://hdfs-nn:8020/user/a/data.har/f.txt?ver=1\");\nFileSystem fs = p.getFileSystem(conf); // IOException: query component in Path not supported\n\n// after\nPath p = new Path(\"har://hdfs-nn:8020/user/a/data.har/f.txt\");","handlingStrategy":"validation","validationCode":"URI u = path.toUri();\nif (u.getQuery() != null) {\n  throw new IllegalArgumentException(\"har:// paths must not contain a query component: \" + path);\n}","typeGuard":null,"tryCatchPattern":"try {\n  FileSystem fs = path.getFileSystem(conf);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"query component\")) {\n    throw new IllegalArgumentException(\"Misconfigured path (query string not allowed): \" + path, e);\n  }\n  throw e;\n}","preventionTips":["Build har:// paths from URI components (new URI(scheme, authority, path, null, null)) instead of string concatenation","Validate paths once at configuration load time rather than at first FileSystem use","Percent-encode literal '?' characters in file names when constructing Paths"],"tags":["hadoop","har-filesystem","uri","path","initialization"],"backgroundTag":"invalid-uri-format","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}