{"record":{"id":"62d28cab4fca1ca2","repo":"NationalSecurityAgency/ghidra","slug":"can-only-directly-delete-values-for-maps-where-the","errorCode":null,"errorMessage":"Can only directly delete values for maps where the entry is the value","messagePattern":"Can only directly delete values for maps where the entry is the value","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/map/DBTraceAddressSnapRangePropertyMap.java","lineNumber":117,"sourceCode":"\t\t\tboolean createIfAbsent) {\n\t\treturn super.getForSpace(space, createIfAbsent);\n\t}\n\n\t@Override\n\tpublic Lock readLock() {\n\t\treturn lock.readLock();\n\t}\n\n\t@Override\n\tpublic Lock writeLock() {\n\t\treturn lock.writeLock();\n\t}\n\n\t@Override\n\t@SuppressWarnings({ \"unchecked\" })\n\tpublic void deleteValue(T value) {\n\t\tif (!(value instanceof AbstractDBTraceAddressSnapRangePropertyMapData)) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\"Can only directly delete values for maps where the entry is the value\");\n\t\t}\n\t\tdeleteData((DR) value);\n\t}\n\n\t// NOTE: DR is not declared in interface\n\tpublic void deleteData(DR data) {\n\t\tAddressSpace space = data.range.getAddressSpace();\n\t\tdelegateDeleteV(space, m -> m.deleteData(data));\n\t}\n\n\t@Override\n\tpublic T put(TraceAddressSnapRange shape, T value) {\n\t\treturn delegateWrite(shape.getRange().getAddressSpace(), m -> m.put(shape, value));\n\t}\n\n\t@Override\n\tpublic boolean remove(TraceAddressSnapRange shape, T value) {","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/map/DBTraceAddressSnapRangePropertyMap.java#L99-L135","documentation":"Thrown by DBTraceAddressSnapRangePropertyMap.deleteValue(T value) when the value passed is not an instance of AbstractDBTraceAddressSnapRangePropertyMapData. The map-level deleteValue method can only delete values that are themselves map entry data objects (where the entry IS the value). For maps where values are separate from entries, you must use deleteData() with the entry instead. This is an IllegalArgumentException (unchecked).","triggerScenarios":"Calling deleteValue(someValue) on a DBTraceAddressSnapRangePropertyMap where someValue is a plain domain object (e.g., a String, Integer, or custom value) rather than an AbstractDBTraceAddressSnapRangePropertyMapData instance. This happens when the caller treats the property map like a generic key-value store without understanding the entry-as-value constraint.","commonSituations":"Using a DBTraceAddressSnapRangePropertyMap with a value type that is not the entry data class. Generic map manipulation code that assumes deleteValue accepts any value type.","solutions":["Use the remove(TraceAddressSnapRange shape, T value) or remove(Entry) methods instead of deleteValue() for non-entry values.","If using a map where the value IS the entry (e.g., DBTraceStringPropertyMapEntry), ensure you pass the entry data object, not the raw value.","Check value instanceof AbstractDBTraceAddressSnapRangePropertyMapData before calling deleteValue()."],"exampleFix":"// before\nmap.deleteValue(myValue);\n\n// after\n// Use remove by shape instead\nmap.remove(shape, myValue);\n// Or if value is the entry:\nif (myValue instanceof AbstractDBTraceAddressSnapRangePropertyMapData) {\n    map.deleteValue(myValue);\n}","handlingStrategy":"validation","validationCode":"// Check before calling deleteValue on the map\nif (value instanceof AbstractDBTraceAddressSnapRangePropertyMapData) {\n    map.deleteValue(value);\n} else {\n    // use remove(shape, value) or remove(entry) instead\n}","typeGuard":"// Type guard for safe deleteValue calls\nstatic <T> boolean isEntryValue(T value) {\n    return value instanceof AbstractDBTraceAddressSnapRangePropertyMapData;\n}","tryCatchPattern":null,"preventionTips":["Understand the difference between deleteValue() (entry-as-value maps only) and remove() (general).","Prefer remove(shape, value) or remove(entry) for non-entry-value maps.","Check instanceof AbstractDBTraceAddressSnapRangePropertyMapData before deleteValue()."],"tags":["property-map","trace-database","map-operation","unchecked-exception","type-mismatch"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}