{"record":{"id":"59bb85b51da7f012","repo":"NationalSecurityAgency/ghidra","slug":"value-is-not-a-known-settings-type","errorCode":null,"errorMessage":"Value is not a known settings type","messagePattern":"Value is not a known settings type","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/data/DBTraceDataSettingsOperations.java","lineNumber":42,"sourceCode":"import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree.TraceAddressSnapRangeQuery;\nimport ghidra.trace.model.Lifespan;\nimport ghidra.trace.model.map.TraceAddressSnapRangePropertyMapOperations;\nimport ghidra.util.LockHold;\n\npublic interface DBTraceDataSettingsOperations\n\t\textends TraceAddressSnapRangePropertyMapOperations<DBTraceSettingsEntry> {\n\n\tstatic void assertKnownType(Object obj) {\n\t\tif (obj instanceof Long) {\n\t\t\treturn;\n\t\t}\n\t\tif (obj instanceof String) {\n\t\t\treturn;\n\t\t}\n\t\tif (obj instanceof byte[]) {\n\t\t\treturn;\n\t\t}\n\t\tthrow new IllegalArgumentException(\"Value is not a known settings type\");\n\t}\n\n\tvoid makeWay(DBTraceSettingsEntry entry, Lifespan span);\n\n\tReadWriteLock getLock();\n\n\tdefault DBTraceSettingsEntry doGetExactEntry(Lifespan lifespan, Address address,\n\t\t\tString name) {\n\t\tfor (DBTraceSettingsEntry entry : reduce(\n\t\t\tTraceAddressSnapRangeQuery.at(address, lifespan.lmin())).values()) {\n\t\t\tif (!lifespan.equals(entry.getLifespan())) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!name.equals(entry.name)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn entry;\n\t\t}","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/data/DBTraceDataSettingsOperations.java#L24-L60","documentation":"assertKnownType permits only Long, String, and byte[] as trace settings values; any other type throws IllegalArgumentException(\"Value is not a known settings type\"). The DB settings codec persists only those three forms, so the type is constrained at the API boundary. Note Integer/Double/Boolean are NOT accepted (must be widened to Long or serialized).","triggerScenarios":"Calling a settings setter on DBTraceDataSettingsOperations with an Integer, Short, Byte, Double, Float, Boolean, or arbitrary object.","commonSituations":"Assuming settings accept any boxed primitive; passing an enum or custom Serializable; forgetting to widen int to long.","solutions":["Widen integer types to Long before storing.","Serialize non-numeric types to String or byte[].","Run a type guard (instanceof Long/String/byte[]) before calling the setter."],"exampleFix":"// before\nops.setSetting(span, addr, \"count\", Integer.valueOf(5));\n\n// after\nops.setSetting(span, addr, \"count\", Long.valueOf(5));","handlingStrategy":"type-guard","validationCode":"static void checkSettingValue(Object v) {\n    if (!(v instanceof Long || v instanceof String || v instanceof byte[]))\n        throw new IllegalArgumentException(\"settings value must be Long, String, or byte[]\");\n}","typeGuard":"static boolean isKnownSettingType(Object v) {\n    return v instanceof Long || v instanceof String || v instanceof byte[];\n}","tryCatchPattern":null,"preventionTips":["Always widen int/short/byte to Long before storing as a setting.","Serialize enums/objects to String rather than storing them directly.","Wrap all settings setters with a centralized type guard."],"tags":["settings","type-validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}