NationalSecurityAgency/ghidra · error · ElasticException
Error parsing URL:
Error message
Error parsing URL:
What it means
URISyntaxException handler inside executeBulk. executeBulk builds its URL from the raw hostURL (NOT the repo-scoped httpURLbase) plus the path, with Content-Type application/x-ndjson. This fires when hostURL + path is not a valid URI.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java:374
HttpURLConnection connection = null;
try {
URL httpURL = new URI(hostURL + path).toURL();
connection = (HttpURLConnection) httpURL.openConnection();
connection.setRequestMethod(POST);
connection.setRequestProperty("Content-Type", "application/x-ndjson");
connection.setDoOutput(true);
try (Writer writer = new OutputStreamWriter(connection.getOutputStream())) {
writer.write(body);
}
lastResponseCode = connection.getResponseCode();
JsonObject resp = grabResponse(connection);
if (!lastRequestSuccessful()) {
throw new ElasticException(parseErrorJSON(resp));
}
return resp;
}
catch (URISyntaxException e) {
throw new ElasticException("Error parsing URL: " + e.getMessage());
}
catch (IOException e) {
throw new ElasticException("Error sending request: " + e.getMessage());
}
catch (JsonParseException e) {
throw new ElasticException("Error parsing response: " + e.getMessage());
}
finally {
if (connection != null) {
connection.disconnect();
}
}
}
public JsonObject executeURIOnly(String command, String path) throws ElasticException {
HttpURLConnection connection = null;
try {
URL httpURL = new URI(httpURLbase + path).toURL();View on GitHub (pinned to d5f144c24d)
Solutions
- Keep hostURL as scheme://host:port with no trailing slash and pass a literal, well-known bulk path.
- Percent-encode any dynamic part of the bulk path with URLEncoder.encode(seg, UTF_8).
- Pre-validate with URI.create(hostURL + path) to surface the exact bad character.
Example fix
// before
c.executeBulk("_bulk?refresh=true " + userTag, ndjson);
// after
c.executeBulk("_bulk?refresh=" + URLEncoder.encode(userTag, UTF_8), ndjson); Defensive patterns
Strategy: validation
Validate before calling
public static String safeBulkPath(String hostUrl, String path) {
String base = hostUrl.replaceAll("/+$", "");
URI.create(base); // validate host URL
URI.create(base + "/" + path); // validate full bulk URL
return path;
} Try / catch
try {
return conn.executeBulk(path, ndjson);
} catch (ElasticException e) {
if (e.getMessage().startsWith("Error parsing URL"))
throw new IllegalArgumentException("Invalid bulk path: " + path, e);
throw e;
} Prevention
- Keep hostURL as scheme://host:port with no trailing slash.
- Pass a literal well-known bulk path; encode any dynamic query param.
- Validate the full URL shape once at startup, not per bulk call.
When it happens
Trigger: Bulk path argument (typically '_bulk' or a prefixed variant) containing a space or symbol; hostURL with a space, non-ASCII host, or trailing slash producing '//'; unencoded dynamic segment in the bulk path.
Common situations: Constructing the bulk path from user/derived input without encoding; copy-pasted ES URL with whitespace; mixed http/https scheme typo.
Related errors
- Invalid in URL
- Cannot have signature setting of 0
- drop database name must match
- Too many {type} specified (limit={MAX_TAG_COUNT}): {list.siz
- URL path must indicate the repository only
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/175c2df4a95cb721.
Report an issue: GitHub.