{"record":{"id":"0efb1239937cdd67","repo":"alibaba/nacos","slug":"unknown-theme-value","errorCode":null,"errorMessage":"Unknown theme: {value}","messagePattern":"Unknown theme: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/com/alibaba/nacos/api/ai/model/mcp/registry/Icon.java","lineNumber":237,"sourceCode":"        @JsonValue\n        public String getValue() {\n            return value;\n        }\n        \n        /**\n         * Create from value.\n         *\n         * @param value value\n         * @return Theme\n         */\n        @JsonCreator\n        public static Theme fromValue(String value) {\n            for (Theme t : Theme.values()) {\n                if (t.value.equalsIgnoreCase(value)) {\n                    return t;\n                }\n            }\n            throw new IllegalArgumentException(\"Unknown theme: \" + value);\n        }\n    }\n}\n","sourceCodeStart":219,"sourceCodeEnd":241,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/api/src/main/java/com/alibaba/nacos/api/ai/model/mcp/registry/Icon.java#L219-L241","documentation":"Icon.Theme.fromValue (a Jackson @JsonCreator) throws IllegalArgumentException when the input does not case-insensitively match 'light' or 'dark'. This fires during JSON deserialization of an Icon object whose theme field has an unrecognized value.","triggerScenarios":"Deserializing JSON with a theme value like 'Light', 'DARK', 'medium', 'auto', 'system', or any string other than the two allowed values. While case-insensitive matching covers 'LIGHT' and 'Dark', anything else fails.","commonSituations":"A third-party system sends a theme value outside the spec. A UI component defaults to 'auto' or 'system'. A locale or locale-influenced serialization produced an unexpected value.","solutions":["Normalize the theme value to 'light' or 'dark' before building or sending the Icon.","If the source cannot be controlled, pre-process the JSON or use a custom Jackson deserializer that defaults unknown themes to 'light'.","Validate the theme field at the API boundary."],"exampleFix":"// before\n{ \"src\": \"icon.png\", \"mimeType\": \"image/png\", \"theme\": \"auto\" } // throws\n\n// after\n{ \"src\": \"icon.png\", \"mimeType\": \"image/png\", \"theme\": \"light\" } // ok\n\n// Pre-process:\nString theme = Set.of(\"light\",\"dark\").contains(rawTheme.toLowerCase())\n    ? rawTheme.toLowerCase() : \"light\";","handlingStrategy":"validation","validationCode":"private static final Set<String> VALID_THEMES = Set.of(\"light\", \"dark\");\n\nString normalized = rawTheme == null ? null : rawTheme.trim().toLowerCase();\nif (!VALID_THEMES.contains(normalized)) {\n    normalized = \"light\"; // or reject\n}","typeGuard":"public static boolean isValidTheme(String value) {\n    if (value == null) return false;\n    String v = value.trim().toLowerCase();\n    return \"light\".equals(v) || \"dark\".equals(v);\n}","tryCatchPattern":"try {\n    Icon icon = objectMapper.readValue(json, Icon.class);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Unknown theme\")) {\n        // default to 'light' and retry\n    }\n    throw e;\n}","preventionTips":["Normalize theme values to 'light' or 'dark' before building Icon objects.","Validate at the API boundary for external/third-party payloads.","Consider a custom Jackson deserializer that defaults unknown themes."],"tags":["mcp","icon","jackson","enum","theme","deserialization"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}