{"record":{"id":"508e3821aad74a2a","repo":"NationalSecurityAgency/ghidra","slug":"no-codec-for-type","errorCode":null,"errorMessage":"No codec for type {}","messagePattern":"No codec for type (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/ProposedUtils/src/main/java/ghidra/framework/plugintool/AutoConfigState.java","lineNumber":492,"sourceCode":"\t\t}\n\n\t\t/**\n\t\t * Put an object into a {@link SaveState} using a known codec\n\t\t * \n\t\t * <p>\n\t\t * This seems like something that should be in SaveState itself, but the object value must\n\t\t * be one of the supported types.\n\t\t * \n\t\t * @param <T> the type of the value\n\t\t * @param state the state to write into\n\t\t * @param type the type of the value\n\t\t * @param name the name of the name-value pair\n\t\t * @param value the value of the name-value pair\n\t\t */\n\t\tpublic static <T> void putState(SaveState state, Class<T> type, String name, T value) {\n\t\t\tConfigFieldCodec<T> codec = getCodecByType(type);\n\t\t\tif (codec == null) {\n\t\t\t\tthrow new IllegalArgumentException(\"No codec for type \" + type);\n\t\t\t}\n\t\t\tcodec.write(state, name, value);\n\t\t}\n\n\t\t/**\n\t\t * Get an object from a {@link SaveState} using a known codec\n\t\t * \n\t\t * <p>\n\t\t * This seems like something that should be in SaveState itself.\n\t\t * \n\t\t * @param <T> the type of the value\n\t\t * @param state the state to read from\n\t\t * @param type the expected type of the value\n\t\t * @param name the name of the name-value pair\n\t\t * @return the value of the name-value pair\n\t\t */\n\t\tpublic static <T> T getState(SaveState state, Class<T> type, String name) {\n\t\t\tConfigFieldCodec<T> codec = getCodecByType(type);","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/framework/plugintool/AutoConfigState.java#L474-L510","documentation":"Thrown by AutoConfigState.ConfigStateField.putState() when getCodecByType(type) returns null, i.e., the value's type has no registered ConfigFieldCodec. SaveState only supports a fixed set of primitive/wrapper/String/array/File/Path/Enum/BigInteger types; any other type cannot be serialized and registration aborts. The message names the unsupported type.","triggerScenarios":"Calling putState with a type not in the codec registry, such as a custom POJO, a List, a Map, LocalDate, or an arbitrary domain class. An @AutoConfigStateField whose field type lacks a codec and whose annotation codec() defaults to DefaultConfigFieldCodec.","commonSituations":"Adding a config field of an unsupported type without supplying a custom codec; expecting SaveState to handle arbitrary objects; version upgrades that introduce new field types.","solutions":["Use a supported type (String, int, boolean, enum, File, Path, BigInteger, or a primitive array).","Implement a ConfigFieldCodec<T> for the custom type and reference it via @AutoConfigStateField(codec=MyCodec.class).","Serialize the custom object to a String or byte[] and store that instead."],"exampleFix":"// before\nConfigStateField.putState(state, MyPojo.class, \"pojo\", pojo); // no codec\n\n// after\n// option A: convert to supported type\nConfigStateField.putState(state, String.class, \"pojo\", pojo.toJson());\n// option B: register a custom codec via @AutoConfigStateField(codec = MyPojoCodec.class)","handlingStrategy":"validation","validationCode":"ConfigFieldCodec<?> codec = AutoConfigState.ConfigStateField.getCodecByType(type);\nif (codec == null) {\n  throw new IllegalStateException(\"No codec for \" + type + \"; convert or register one\");\n}\nConfigStateField.putState(state, type, name, value);","typeGuard":"static boolean hasCodec(Class<?> type) {\n  return AutoConfigState.ConfigStateField.getCodecByType(type) != null;\n}","tryCatchPattern":null,"preventionTips":["Use only supported types or supply a custom ConfigFieldCodec.","Convert custom objects to String/byte[] before storing.","Keep a list of supported types handy when adding config fields."],"tags":["ghidra","config-state","serialization","unsupported-type"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}