{"record":{"id":"167016fb9626476c","repo":"NationalSecurityAgency/ghidra","slug":"could-not-determine-option-type-from-default-value","errorCode":null,"errorMessage":"Could not determine option type from default value: {} = {}","messagePattern":"Could not determine option type from default value: (.+?) = (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/ProposedUtils/src/main/java/ghidra/framework/options/AutoOptions.java","lineNumber":144,"sourceCode":"\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tf.setAccessible(true);\n\t\t\tHelpLocation help = getHelpLocation(plugin.getName(), annotation.help());\n\t\t\tObject defaultValue;\n\t\t\ttry {\n\t\t\t\tdefaultValue = f.get(receiver);\n\t\t\t}\n\t\t\tcatch (IllegalArgumentException | IllegalAccessException e) {\n\t\t\t\tthrow new AssertionError(e);\n\t\t\t}\n\n\t\t\tOptionType type = annotation.type();\n\t\t\tif (type == OptionType.NO_TYPE) {\n\t\t\t\ttype = OptionType.getOptionType(defaultValue);\n\t\t\t\t// TODO: OptionType does have getValueClass, if searching by class is better\n\t\t\t}\n\t\t\tif (type == OptionType.NO_TYPE) {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"Could not determine option type from default value: \" + f + \" = \" +\n\t\t\t\t\t\tdefaultValue);\n\t\t\t}\n\n\t\t\tString description = annotation.description();\n\t\t\tClass<? extends PropertyEditor> editorClass = annotation.editor();\n\t\t\tfinal PropertyEditor editor;\n\t\t\tif (editorClass == PropertyEditor.class || SystemUtilities.isInHeadlessMode()) {\n\t\t\t\teditor = null;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttry {\n\t\t\t\t\teditor = editorClass.getConstructor().newInstance();\n\t\t\t\t}\n\t\t\t\tcatch (InstantiationException | IllegalAccessException | IllegalArgumentException\n\t\t\t\t\t\t| InvocationTargetException | NoSuchMethodException | SecurityException e) {\n\t\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"editor class must have accessible default constructor\", e);","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/framework/options/AutoOptions.java#L126-L162","documentation":"Thrown by AutoOptions.registerOptionsDefined() when an @AutoOptionDefined field's option type cannot be inferred. The annotation's type() defaults to NO_TYPE, and if the field's default value also does not map to a known OptionType (via OptionType.getOptionType), registration aborts because Ghidra cannot store or edit the option without a concrete type.","triggerScenarios":"An @AutoOptionDefined field whose default value is null or an unsupported type, with type() left at NO_TYPE. A field typed as a custom class that OptionType does not recognize. A field with no initializer giving a null default.","commonSituations":"Adding an option field with a custom/complex type not covered by OptionType; forgetting to set type() on the annotation; leaving a reference field uninitialized so the default is null.","solutions":["Set an explicit type() on @AutoOptionDefined (e.g. OptionType.INT, OptionType.STRING, OptionType.BOOLEAN).","Ensure the field's default value is a type OptionType recognizes (String, int, double, boolean, etc.).","Initialize the field so its default is non-null and type-inferable.","If a custom type is needed, supply a PropertyEditor via the editor() attribute and a concrete type()."],"exampleFix":"// before\n@AutoOptionDefined(description = \"timeout\")\nprivate Object timeout; // null default, NO_TYPE -> throws\n\n// after\n@AutoOptionDefined(type = OptionType.INT, description = \"timeout\")\nprivate int timeout = 30;","handlingStrategy":"validation","validationCode":"OptionType t = annotation.type();\nif (t == OptionType.NO_TYPE) {\n  t = OptionType.getOptionType(defaultValue);\n}\nif (t == OptionType.NO_TYPE) {\n  throw new IllegalStateException(\"Set explicit type() on @AutoOptionDefined for \" + f);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set type() explicitly on @AutoOptionDefined.","Initialize option fields with a supported default value.","Avoid custom-typed option fields unless paired with a PropertyEditor."],"tags":["ghidra","options","annotation","type-inference"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}