NationalSecurityAgency/ghidra · error · IllegalArgumentException

CreateTrace: path (name) cannot be empty

Error message

CreateTrace: path (name) cannot be empty

What it means

Thrown by TraceRmiHandler.handleCreateTrace after sanitizePath() reduces the requested path to an empty list. A CreateTrace request must name the new trace (the last path element is the file name), so an empty path is rejected with IllegalArgumentException. The path is sanitized (stripping empties from components like '//' or trailing '/'), which can turn a non-empty string into an empty list.

Source

Thrown at Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/tracermi/TraceRmiHandler.java:869

		OpenTrace open = requireOpenTrace(req.getOid());
		XmlSchemaContext ctx;
		try {
			ctx = XmlSchemaContext.deserialize(req.getSchemaContext());
		}
		catch (Exception e) {
			throw new InvalidSchemaError(e);
		}
		TraceObjectValue value = open.trace.getObjectManager()
				.createRootObject(ctx.getSchema(new SchemaName(req.getRootSchema())));
		return ReplyCreateObject.newBuilder().setObject(makeObjSpec(value.getChild())).build();
	}

	protected ReplyCreateTrace handleCreateTrace(RequestCreateTrace req)
			throws InvalidNameException, IOException, CancelledException {
		DomainFolder traces = getOrCreateNewTracesFolder();
		List<String> path = sanitizePath(req.getPath().getPath());
		if (path.isEmpty()) {
			throw new IllegalArgumentException("CreateTrace: path (name) cannot be empty");
		}
		DomainFolder folder = createFolders(traces, path.subList(0, path.size() - 1));
		CompilerSpec cs = requireCompilerSpec(req.getLanguage(), req.getCompiler());
		DBTrace trace = new DBTrace(path.get(path.size() - 1), cs, this);
		TraceRmiTarget target = new TraceRmiTarget(plugin.getTool(), this, trace);
		DoId doId = requireAvailableDoId(req.getOid());
		openTraces.put(new OpenTrace(doId, trace, target));
		createDeconflictedFile(folder, trace);
		doActivate(null, trace, null);
		return ReplyCreateTrace.getDefaultInstance();
	}

	protected static String sanitizeName(String name) {
		StringBuffer buf = new StringBuffer(name.length());
		for (int i = 0; i < name.length(); i++) {
			char c = name.charAt(i);
			buf.append(LocalFileSystem.isValidNameCharacter(c) ? c : '_');
		}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Provide a non-empty name as the final path component when building the CreateTrace request.
  2. Validate the path is non-empty and contains at least one non-slash segment before sending.
  3. Strip slashes/whitespace client-side and reject empty results before the call.

Example fix

# before
path = ''  # or '//' -> sanitized to empty
conn.create_trace(path, lang, compiler)

# after
name = 'my_trace'
assert name and name.strip('/'), 'trace name required'
conn.create_trace(name, lang, compiler)
Defensive patterns

Strategy: validation

Validate before calling

List<String> path = sanitizePath(req.getPath().getPath());
if (path.isEmpty()) {
    throw new IllegalArgumentException("trace name required");
}

Try / catch

try {
    handler.createTrace(req);
} catch (IllegalArgumentException e) {
    // empty path; prompt user / supply a name and retry
}

Prevention

When it happens

Trigger: The client sends RequestCreateTrace with an empty path string, a path of only slashes ('/', '//'), or a path whose components are all empty after sanitization.

Common situations: Client forgets to set the trace name; path built by joining an empty list; user supplied a blank name in the UI/script; path is just whitespace/slashes.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/f21a6f3e243f7c54. Report an issue: GitHub.