NationalSecurityAgency/ghidra · error · IllegalArgumentException

Column {} is not of type {}! It is {}

Error message

Column {} is not of type {}! It is {}

What it means

Thrown (unchecked IllegalArgumentException) by getIndex(fieldClass, columnIndex) when the fieldClass passed by the caller does not match the column codec's actual value type (codec.getValueType()). The index is typed by its codec; requesting it with the wrong type would cause unsafe casts, so the type is verified.

Source

Thrown at Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/DBCachedObjectStore.java:1005

	/**
	 * Get the table index for the given column number
	 * 
	 * @param <K> the type of the object field for the indexed column
	 * @param fieldClass the class specifying {@link K}
	 * @param columnIndex the column number
	 * @return the index
	 * @throws IllegalArgumentException if the column has a different type than {@link K}
	 */
	protected <K> DBCachedObjectIndex<K, T> getIndex(Class<K> fieldClass, int columnIndex) {
		if (!ArrayUtils.contains(table.getIndexedColumns(), columnIndex)) {
			throw new IllegalArgumentException(
				"Column " + schema.getFieldNames()[columnIndex] + " is not indexed");
		}

		DBFieldCodec<?, T, ?> codec = codecs.get(columnIndex);
		Class<?> exp = codec.getValueType();
		if (fieldClass != exp) {
			throw new IllegalArgumentException("Column " + schema.getFieldNames()[columnIndex] +
				" is not of type " + fieldClass + "! It is " + exp);
		}
		@SuppressWarnings("unchecked")
		DBFieldCodec<K, T, ?> castCodec = (DBFieldCodec<K, T, ?>) codec;
		return new DBCachedObjectIndex<>(this, adapter, castCodec, columnIndex, FieldSpan.ALL,
			Direction.FORWARD);
	}

	/**
	 * Get the index for a given column
	 * 
	 * <p>
	 * See {@link DBCachedObjectStoreFactory} for an example that includes use of an index
	 * 
	 * @param <K> the type of the object field for the indexed column
	 * @param fieldClass the class specifying {@link K}
	 * @param column the indexed column
	 * @return the index

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Match fieldClass to the column's codec value type (inspect codec.getValueType() or the declared field type).
  2. Keep a single source of truth for each column's type and derive both the schema declaration and the index request from it.
  3. After changing a field's type, update every getIndex call site that references that column.

Example fix

// before
DBCachedObjectIndex<Long,T> idx = store.getIndex(Long.class, nameCol); // throws if column is String-typed

// after: use the column's actual value type
Class<?> actual = store.getCodec(nameCol).getValueType();
DBCachedObjectIndex<?,T> idx = store.getIndex(actual, nameCol);
Defensive patterns

Strategy: validation

Validate before calling

// Match fieldClass to the column's codec value type
Class<?> actual = codecs.get(columnIndex).getValueType();
if (fieldClass != actual) {
    // type mismatch: pass `actual` (or align the schema) instead
}

Prevention

When it happens

Trigger: Calling getIndex(Long.class, col) on a column whose codec value type is String (or vice versa) — a type/class mismatch between what the caller believes the column stores and its declared codec type.

Common situations: Schema/column-type confusion; refactoring a field's type but not updating the index lookup call; copy-pasting an index request from a different column; using a boxed type where primitive-backed type is expected or the reverse.

Related errors


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