{"record":{"id":"3eaacc930c3c899b","repo":"apache/hadoop","slug":"invalid-uri-s-3eaacc","errorCode":null,"errorMessage":"Invalid URI %s","messagePattern":"Invalid URI (.+?)","errorType":"validation","errorClass":"InvalidUriException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java","lineNumber":1229,"sourceCode":"  }\n\n  /**\n   * Creates REST operation URL with given baseUrl, path and query.\n   * @param baseUrl to be used for the operation.\n   * @param path for which URL has to be created.\n   * @param query to be added to the URL.\n   * @return URL for the REST operation.\n   * @throws AzureBlobFileSystemException if URL creation fails.\n   */\n  @VisibleForTesting\n  protected URL createRequestUrl(final URL baseUrl, final String path, final String query)\n          throws AzureBlobFileSystemException {\n    String encodedPath = path;\n    try {\n      encodedPath = urlEncode(path);\n    } catch (AzureBlobFileSystemException ex) {\n      LOG.debug(\"Unexpected error.\", ex);\n      throw new InvalidUriException(path);\n    }\n\n    final StringBuilder sb = new StringBuilder();\n    if (baseUrl == null) {\n      throw new InvalidUriException(\"URL provided is null\");\n    }\n    sb.append(baseUrl.toString());\n    sb.append(encodedPath);\n    sb.append(query);\n\n    final URL url;\n    try {\n      url = new URL(sb.toString());\n    } catch (MalformedURLException ex) {\n      throw new InvalidUriException(\"URL is malformed\" + sb.toString());\n    }\n    return url;\n  }","sourceCodeStart":1211,"sourceCodeEnd":1247,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java#L1211-L1247","documentation":"Defensive wrapper in createRequestUrl: encoding the path with urlEncode() threw an AzureBlobFileSystemException (concretely InvalidUriException from the encoder), so the request URL cannot be built. The message carries the offending path, which is the string that failed to encode.","triggerScenarios":"A request path reaches createRequestUrl with content the URL encoder rejects — in practice an UnsupportedEncodingException from encoding, or a corrupted/invalid path string produced upstream by path-conversion logic.","commonSituations":"Exotic or corrupted path strings (non-String-normalized data, invalid surrogate pairs) coming from listing/conversion code; JVMs with broken charset support; paths containing NUL or control characters injected by user jobs.","solutions":["Log the path value from the exception and inspect it for control characters or broken Unicode.","Sanitize/validate user-supplied paths before passing them to the Azure filesystem.","If it reproduces on a standard path, check the JVM's charset support and switch to a standard JDK distribution."],"exampleFix":"// before\nfs.create(new Path(userInput)); // userInput contains a NUL/control char\n// after\nif (userInput.chars().anyMatch(c -> c < 0x20 || c == 0x7f)) {\n  throw new IllegalArgumentException(\"Illegal characters in path: \" + userInput);\n}\nfs.create(new Path(userInput));","handlingStrategy":"validation","validationCode":"if (path == null || path.chars().anyMatch(c -> c < 0x20 || c == 0x7f)) {\n  throw new IllegalArgumentException(\"Illegal path characters: \" + path);\n}","typeGuard":null,"tryCatchPattern":"catch (InvalidUriException ex) {\n  // ex.getMessage() holds the offending path: log it, reject the input record\n}","preventionTips":["Sanitize externally sourced path strings before handing them to the Azure filesystem.","Keep JVM/runtime standard so UTF-8 encoding always succeeds.","Log raw inputs when path validation rejects them, to trace which producer emitted bad data."],"tags":["azure","abfs","uri","url-encoding","validation"],"backgroundTag":"invalid-uri","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}