NationalSecurityAgency/ghidra · warning · LSHException

Function tag already exists

Error message

Function tag already exists

What it means

fdbInstallTag checks info.functionTags.contains(query.tag_name); if present it throws LSHException("Function tag already exists").

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java:2963

		response.info = info;
	}

	/**
	 * Entry point for the Elasticsearch version of InstallTagRequest command:
	 *   Install a new function tag to be managed by this data
	 * @param query is command parameters
	 * @throws LSHException if the command is misconfigured
	 * @throws ElasticException for communication problems with the server
	 */
	private void fdbInstallTag(InstallTagRequest query) throws LSHException, ElasticException {
		final ResponseInfo response = query.installresponse;
		if (!CategoryRecord.enforceTypeCharacters(query.tag_name)) {
			throw new LSHException("Bad characters in proposed function tag");
		}
		// Check for existing tag
		if (info.functionTags != null) {
			if (info.functionTags.contains(query.tag_name)) {
				throw new LSHException("Function tag already exists");
			}
		}
		if (info.functionTags == null) {
			info.functionTags = new ArrayList<>();
		}
		// There are only 32-bits of space in the function record reserved for storing the presence of tags
		if (info.functionTags.size() >= FunctionTagBSimFilterType.MAX_TAG_COUNT) {
			throw new LSHException(
				"Cannot allocate new function tag: " + query.tag_name + " - Column space is full");
		}
		info.functionTags.add(query.tag_name);
		writeFunctionTags();
		response.info = info;
	}

	/**
	 * Entry point for the Elasticsearch version of InstallMetadataRequest command:
	 *   Change some of the global meta-data labels for the database.

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Check existing function tags before installing (or treat 'already exists' as success).
  2. Use a unique tag name.

Example fix

// before
installTag(db, name); // throws on re-run
// after
if (!db.getInfo().functionTags.contains(name)) installTag(db, name);
Defensive patterns

Strategy: validation

Validate before calling

List<String> tags = db.getInfo().functionTags != null ? db.getInfo().functionTags : List.of();
if (tags.contains(name)) return; // idempotent skip

Type guard

boolean alreadyInstalled = db.getInfo().functionTags != null && db.getInfo().functionTags.contains(name);

Try / catch

try { db.installTag(req); }
catch (LSHException e) {
    if (e.getMessage().equals("Function tag already exists")) return;
    throw e;
}

Prevention

When it happens

Trigger: Calling InstallTag for a function tag name that already exists in the database.

Common situations: Re-running a tag setup script; an idempotent installer that does not check first.

Related errors


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