NationalSecurityAgency/ghidra · error · MalformedURLException
URL path must indicate the repository only
Error message
URL path must indicate the repository only
What it means
Thrown as a MalformedURLException in the ElasticDatabase(URL) constructor when the full URL string does not end with the URL's path component. The BSim URL format must be a simple http(s)://host:port/<repository> with exactly one path segment. Any query string, fragment, trailing slash, or multi-segment path that causes fullURL to not end with path triggers this exception.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java:2068
builder.toString());
}
/**
* Construct the database connection given a URL. The URL protocol must be http, and the URL
* path must contain exactly one element naming the particular repository on the server.
* @param baseURL is the http URL
* @throws MalformedURLException if the URL is malformed
*/
public ElasticDatabase(URL baseURL) throws MalformedURLException {
String fullURL = baseURL.toString();
if (fullURL.startsWith("elastic:")) {
// https is the true protocol
fullURL = "https:" + fullURL.substring(8);
}
String path = baseURL.getPath();
if (!fullURL.endsWith(path)) {
throw new MalformedURLException("URL path must indicate the repository only");
}
repository = path.substring(1);
this.serverInfo = new BSimServerInfo(DBType.elastic, null, baseURL.getHost(),
baseURL.getPort(), repository);
this.baseURL = fullURL.substring(0, fullURL.length() - path.length());
lastError = null;
info = null;
status = Status.Unconnected;
initialized = false;
}
/**
* @return true if a connection has been successfully initialized
*/
public boolean isInitialized() {
return initialized;
}View on GitHub (pinned to d5f144c24d)
Solutions
- Use a clean URL of the form http://host:port/repository with no query string, fragment, or trailing slash.
- Strip query parameters and fragments before constructing the URL object.
- Ensure exactly one path segment (the repository name) — no nested paths.
- If using the elastic: scheme, ensure it follows the http://host:port/repository pattern after protocol normalization.
Example fix
// before
URL url = new URL("http://localhost:9200/myrepo?refresh=true");
ElasticDatabase db = new ElasticDatabase(url); // throws MalformedURLException
// after
URL url = new URL("http://localhost:9200/myrepo");
ElasticDatabase db = new ElasticDatabase(url); Defensive patterns
Strategy: validation
Validate before calling
// Validate the URL before constructing ElasticDatabase
String urlStr = baseURL.toString();
if (urlStr.contains("?") || urlStr.contains("#")) {
throw new IllegalArgumentException(
"BSim URL must not contain query parameters or fragments: " + urlStr);
}
String path = baseURL.getPath();
if (path == null || path.isEmpty() || path.equals("/") || path.indexOf('/', 1) != -1) {
throw new IllegalArgumentException(
"BSim URL path must be a single repository segment: " + path);
}
if (!urlStr.endsWith(path)) {
throw new IllegalArgumentException(
"URL must end with the repository path: " + urlStr);
} Try / catch
try {
ElasticDatabase db = new ElasticDatabase(new URL(urlString));
} catch (MalformedURLException e) {
if (e.getMessage().contains("URL path must indicate the repository only")) {
// Strip query/fragment and retry with a clean URL
urlString = urlString.replaceAll("[?#].*$", "");
ElasticDatabase db = new ElasticDatabase(new URL(urlString));
} else {
throw e;
}
} Prevention
- Always construct BSim URLs as http://host:port/repository with no query string or fragment.
- Validate the URL format before passing it to the ElasticDatabase constructor.
- Centralize URL construction in a helper method to prevent malformed inputs.
When it happens
Trigger: Constructing an ElasticDatabase with a URL whose toString() does not end with baseURL.getPath(). For example, a URL with query parameters (?param=value) causes the full string to end with the query, not the path; a URL with a fragment (#section) has the same effect.
Common situations: Passing a URL with authentication query parameters; URL with a trailing slash (/repo/); URL constructed by concatenating extra path segments; passing an elastic: protocol URL that was not properly normalized.
Related errors
- Bad database URL: ${e.getMessage()}
- Invalid in URL
- Cannot have signature setting of 0
- drop database name must match
- Too many {type} specified (limit={MAX_TAG_COUNT}): {list.siz
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/dd9451a398e955fe.
Report an issue: GitHub.