apache/hadoop · error · InvalidUriException
Invalid URI %s
Error message
Invalid URI %s
What it means
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.
Source
Thrown at hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java:1229
}
/**
* Creates REST operation URL with given baseUrl, path and query.
* @param baseUrl to be used for the operation.
* @param path for which URL has to be created.
* @param query to be added to the URL.
* @return URL for the REST operation.
* @throws AzureBlobFileSystemException if URL creation fails.
*/
@VisibleForTesting
protected URL createRequestUrl(final URL baseUrl, final String path, final String query)
throws AzureBlobFileSystemException {
String encodedPath = path;
try {
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;
}View on GitHub (pinned to 2add963021)
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.
Example fix
// before
fs.create(new Path(userInput)); // userInput contains a NUL/control char
// after
if (userInput.chars().anyMatch(c -> c < 0x20 || c == 0x7f)) {
throw new IllegalArgumentException("Illegal characters in path: " + userInput);
}
fs.create(new Path(userInput)); Defensive patterns
Strategy: validation
Validate before calling
if (path == null || path.chars().anyMatch(c -> c < 0x20 || c == 0x7f)) {
throw new IllegalArgumentException("Illegal path characters: " + path);
} Try / catch
catch (InvalidUriException ex) {
// ex.getMessage() holds the offending path: log it, reject the input record
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid URI %s
- Default mask is required when a named default acl is present
- Cannot remove user, group or other entry from access ACL.
- Container name must not be null or empty
- Invalid container name (must not contain '/'): {container}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/3eaacc930c3c899b.
Report an issue: GitHub.