NationalSecurityAgency/ghidra · error · MalformedURLException
BSim URL must specify exactly 1 path element
Error message
BSim URL must specify exactly 1 path element
What it means
checkBSimServerURL() enforces that for non-file protocols the URL path has exactly one path element (no '/' after position 1). If path.indexOf('/', 1) >= 0 it means there are nested path segments, which BSim doesn't allow for server-backed databases — the single path element IS the database name.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimClientFactory.java:61
/**
* Validate BSim DB URL.
* Acceptable protocols are postgresql:// https://, (or possibly http://) file:/
* @param url BSim DB URL
* @throws MalformedURLException if the URL string is not a support BSim DB URL
*/
public static void checkBSimServerURL(URL url) throws MalformedURLException {
String protocol = url.getProtocol();
if (!protocol.equals("postgresql") && !protocol.equals("https") &&
!protocol.equals("elastic") && !protocol.equals("file")) {
throw new MalformedURLException("Protocol not permissable for BSim URL");
}
String path = url.getPath();
if (path == null || path.length() == 0 || path.equals("/")) {
throw new MalformedURLException("BSim URL missing DB name/path");
}
if (!"file".equals(protocol) && path.indexOf('/', 1) >= 0) {
throw new MalformedURLException("BSim URL must specify exactly 1 path element");
}
}
/**
* Construct the root URL to a specific BSim repository given a "related" URL.
* The root URL will have an explicit protocol, a hostname + other mods (the authority), and 1 level of path
* this first level path indicates the particular repository being referenced on the host.
* The "related" URL -url- can be an explicitly provided URL pointing to the BSim repository,
* possibly with additional path levels, which are simply stripped from the final root URL.
* Alternately -url- can reference a ghidra server, as indicated by the "ghidra" protocol.
* In this case the true BSim URL is derived from ghidra URL in some way
* @param urlString is the "related" URL
* @return the root BSim URL
* @throws MalformedURLException if the given URL string cannot be parsed
* @throws URISyntaxException if the given URL string cannot be parsed
* @throws IllegalArgumentException if local ghidra URL is specified
*/
public static URL deriveBSimURL(String urlString)View on GitHub (pinned to d5f144c24d)
Solutions
- Reduce the URL path to a single segment: 'postgresql://host/dbname' (remove everything after the first path element).
- If you need to reference a file on disk, use the 'file' protocol which allows multi-level paths.
- Review URL construction logic to ensure only the database name (not a filesystem path) is appended for server protocols.
Example fix
// before String url = "postgresql://myhost/bsim/v1/db"; // multiple path elements // // after String url = "postgresql://myhost/bsimdb"; // single path element
Defensive patterns
Strategy: validation
Validate before calling
String path = url.getPath();
if (!"file".equals(url.getProtocol()) && path.indexOf('/', 1) >= 0) {
// Multiple path segments for a server protocol
throw new IllegalArgumentException(
"Server protocol URLs must have exactly one path element (the database name). Use file:/ for multi-level paths.");
} Try / catch
try {
BSimClientFactory.checkBSimServerURL(url);
} catch (MalformedURLException e) {
if (e.getMessage().contains("exactly 1 path element")) {
// strip extra path segments, keep only the database name
} else {
throw e;
}
} Prevention
- Use only the database name (single segment) for server protocol URLs.
- Switch to file:/ protocol if you need multi-level filesystem paths.
- Avoid joining host + filesystem path when constructing BSim server URLs.
When it happens
Trigger: Calling checkBSimServerURL(url) with a non-file protocol URL where the path contains a second '/'. E.g., 'postgresql://host/dbname/extra' or 'https://host/path/to/db'.
Common situations: User includes a sub-path (thinking BSim needs a full filesystem path); URL constructed by joining host + filesystem path with '/'; user provides a REST-style nested path; copy-paste of a URL from a different system that uses multi-level paths.
Related errors
- Protocol not permissable for BSim URL
- BSim URL missing DB name/path
- URL is not ghidra protocol: {}
- Invalid repository URL: {}
- Unable to infer ghidra URL from BSim file DB URL
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/b0a6205c35086f75.
Report an issue: GitHub.