{"record":{"id":"7f0a22a6479c2272","repo":"NationalSecurityAgency/ghidra","slug":"can-only-directly-delete-values-for-maps-where-the-7f0a22","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":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/map/DBTraceAddressSnapRangePropertyMapSpace.java","lineNumber":85,"sourceCode":"\t@Override\n\tpublic Trace getTrace() {\n\t\treturn trace;\n\t}\n\n\t@Override\n\tpublic AddressSpace getAddressSpace() {\n\t\treturn space;\n\t}\n\n\tpublic <K> DBCachedObjectIndex<K, DR> getUserIndex(Class<K> fieldClass, DBObjectColumn column) {\n\t\treturn tree.getUserIndex(fieldClass, column);\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 UnsupportedOperationException(\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\tpublic void deleteData(DR data) {\n\t\tif (data.tree != this.tree) {\n\t\t\tthrow new IllegalArgumentException(\"The given entry is not in this space\");\n\t\t}\n\t\ttry (LockHold hold = LockHold.lock(lock.writeLock())) {\n\t\t\ttree.doDeleteEntry(data);\n\t\t}\n\t}\n\n\t@Override\n\tpublic T put(TraceAddressSnapRange shape, T value) {\n\t\treturn map.put(shape, value);\n\t}","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/map/DBTraceAddressSnapRangePropertyMapSpace.java#L67-L103","documentation":"Thrown by DBTraceAddressSnapRangePropertyMapSpace.deleteValue(T value) — the per-address-space variant of the same check as error 470. When the value is not an instance of AbstractDBTraceAddressSnapRangePropertyMapData, this space-level method throws UnsupportedOperationException (note: different exception type from the map-level IllegalArgumentException at 470, despite identical message). The space-level deleteValue can only operate when the entry is the value.","triggerScenarios":"Calling deleteValue(someValue) on a DBTraceAddressSnapRangePropertyMapSpace where someValue is not an AbstractDBTraceAddressSnapRangePropertyMapData. This happens when accessing a specific address space's property map directly and passing a raw value object.","commonSituations":"Directly accessing a space-level property map (via getForSpace) and attempting to delete a non-entry value. Generic map cleanup code operating at the space level without checking value types.","solutions":["Use remove(TraceAddressSnapRange shape, T value) on the space instead of deleteValue() for non-entry values.","Use deleteData(DR data) directly if you have the entry data object.","Check value instanceof AbstractDBTraceAddressSnapRangePropertyMapData before calling deleteValue()."],"exampleFix":"// before\nspaceMap.deleteValue(myValue);\n\n// after\nspaceMap.remove(shape, myValue);\n// or if you have the entry:\nif (myValue instanceof AbstractDBTraceAddressSnapRangePropertyMapData<?, ?> entry) {\n    spaceMap.deleteData(entry);\n}","handlingStrategy":"validation","validationCode":"// Check before calling deleteValue on a space map\nif (value instanceof AbstractDBTraceAddressSnapRangePropertyMapData) {\n    spaceMap.deleteValue(value);\n} else {\n    spaceMap.remove(shape, value);\n}","typeGuard":"// Type guard for safe space-level deleteValue\nstatic <T> boolean isEntryValue(T value) {\n    return value instanceof AbstractDBTraceAddressSnapRangePropertyMapData;\n}","tryCatchPattern":null,"preventionTips":["Prefer the top-level map API (map.remove or map.deleteData) which dispatches correctly.","Check value type before calling space-level deleteValue.","Use deleteData(DR) directly when you have the entry data object."],"tags":["property-map","trace-database","map-operation","unchecked-exception","type-mismatch","address-space"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}