{"record":{"id":"7846acb7f5bb45d8","repo":"apache/hadoop","slug":"url-is-malformed-url","errorCode":null,"errorMessage":"URL is malformed{url}","messagePattern":"URL is malformed(.+?)","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":1244,"sourceCode":"      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  }\n\n  /**\n   * returns the url encoded string for a given value.\n   * @param value to be encoded.\n   * @return url encoded string.\n   * @throws AzureBlobFileSystemException if encoding fails.\n   */\n  public static String urlEncode(final String value) throws AzureBlobFileSystemException {\n    String encodedString;\n    try {\n      encodedString =  URLEncoder.encode(value, UTF_8)\n          .replace(PLUS, PLUS_ENCODE)\n          .replace(FORWARD_SLASH_ENCODE, FORWARD_SLASH);\n    } catch (UnsupportedEncodingException ex) {\n        throw new InvalidUriException(value);","sourceCodeStart":1226,"sourceCodeEnd":1262,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java#L1226-L1262","documentation":"The assembled request URL string (baseUrl + encoded path + query) could not be parsed by java.net.URL — MalformedURLException wrapped into InvalidUriException. Some component of the URL (protocol, host, or an unencodable character that survived) is not legal for java.net.URL.","triggerScenarios":"An endpoint URL with a typo in the scheme (e.g. 'abfss:/' or 'https:/'), a host containing illegal characters, or a path segment producing characters that remain invalid after encoding, so new URL(...) throws.","commonSituations":"Hand-edited endpoint configuration with missing slashes; environment variables or templating inserting spaces/newlines into URLs; proxy rewrite rules mangling endpoint URLs; containers built from different distributions whose defaults differ.","solutions":["Print the malformed URL from the exception message and inspect protocol/host for typos or stray whitespace.","Correct the endpoint configuration (scheme https/abfs(s), full storage host).","Check templating/env-var substitution that builds the URL for inserted characters."],"exampleFix":"# before (typo: single slash after scheme)\nfs.azure.account.oauth.provider.msft.endpoint=https:/login.microsoftonline.com/...\n# after\nfs.azure.account.oauth.provider.msft.endpoint=https://login.microsoftonline.com/...\n# preflight any configurable URL\ntry { new URL(candidate); } catch (MalformedURLException e) { failFast(candidate); }","handlingStrategy":"validation","validationCode":"try {\n  new URL(candidateEndpoint);\n} catch (MalformedURLException e) {\n  throw new IllegalArgumentException(\"Bad endpoint URL: \" + candidateEndpoint, e);\n}","typeGuard":null,"tryCatchPattern":"catch (InvalidUriException ex) {\n  if (ex.getMessage().startsWith(\"URL is malformed\")) {\n    // the message embeds the full URL: inspect scheme/host for typos or injected chars\n  } else throw ex;\n}","preventionTips":["Validate all configurable URLs with new URL(...) before starting jobs.","Review templating/env-var substitution that builds endpoint URLs.","Watch for doubled or missing slashes after schemes in hand-edited configs."],"tags":["azure","abfs","url","configuration","malformed-url"],"backgroundTag":"malformed-url","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}