apache/hadoop · error · InvalidUriException
URL is malformed{url}
Error message
URL is malformed{url} What it means
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.
Source
Thrown at hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java:1244
encodedPath = urlEncode(path);
} catch (AzureBlobFileSystemException ex) {
LOG.debug("Unexpected error.", ex);
throw new InvalidUriException(path);
}
final StringBuilder sb = new StringBuilder();
if (baseUrl == null) {
throw new InvalidUriException("URL provided is null");
}
sb.append(baseUrl.toString());
sb.append(encodedPath);
sb.append(query);
final URL url;
try {
url = new URL(sb.toString());
} catch (MalformedURLException ex) {
throw new InvalidUriException("URL is malformed" + sb.toString());
}
return url;
}
/**
* returns the url encoded string for a given value.
* @param value to be encoded.
* @return url encoded string.
* @throws AzureBlobFileSystemException if encoding fails.
*/
public static String urlEncode(final String value) throws AzureBlobFileSystemException {
String encodedString;
try {
encodedString = URLEncoder.encode(value, UTF_8)
.replace(PLUS, PLUS_ENCODE)
.replace(FORWARD_SLASH_ENCODE, FORWARD_SLASH);
} catch (UnsupportedEncodingException ex) {
throw new InvalidUriException(value);View on GitHub (pinned to 2add963021)
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.
Example fix
# before (typo: single slash after scheme)
fs.azure.account.oauth.provider.msft.endpoint=https:/login.microsoftonline.com/...
# after
fs.azure.account.oauth.provider.msft.endpoint=https://login.microsoftonline.com/...
# preflight any configurable URL
try { new URL(candidate); } catch (MalformedURLException e) { failFast(candidate); } Defensive patterns
Strategy: validation
Validate before calling
try {
new URL(candidateEndpoint);
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Bad endpoint URL: " + candidateEndpoint, e);
} Try / catch
catch (InvalidUriException ex) {
if (ex.getMessage().startsWith("URL is malformed")) {
// the message embeds the full URL: inspect scheme/host for typos or injected chars
} else throw ex;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- "%s" must be set for user-bound SAS auth type.
- ABFS endpoint is not set correctly : %s, Do not specify sche
- Invalid URI %s
- Invalid URI %s - account name is not fully qualified.
- Both global key and encryption context are set, only one all
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/7846acb7f5bb45d8.
Report an issue: GitHub.