{"record":{"id":"ff63837d73ad3ca3","repo":"alibaba/nacos","slug":"unknown-mimetype-value","errorCode":null,"errorMessage":"Unknown mimeType: {value}","messagePattern":"Unknown mimeType: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/com/alibaba/nacos/api/ai/model/mcp/registry/Icon.java","lineNumber":184,"sourceCode":"        @JsonValue\n        public String getValue() {\n            return value;\n        }\n        \n        /**\n         * Create from value.\n         *\n         * @param value value\n         * @return MimeType\n         */\n        @JsonCreator\n        public static MimeType fromValue(String value) {\n            for (MimeType t : MimeType.values()) {\n                if (t.value.equalsIgnoreCase(value)) {\n                    return t;\n                }\n            }\n            throw new IllegalArgumentException(\"Unknown mimeType: \" + value);\n        }\n    }\n    \n    /**\n     * Theme enum: light or dark.\n     * Serialized/deserialized as the lowercase string value.\n     */\n    public static enum Theme {\n        \n        /**\n         * Light theme.\n         */\n        LIGHT(\"light\"),\n        /**\n         * Dark theme.\n         */\n        DARK(\"dark\");\n        ","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/api/src/main/java/com/alibaba/nacos/api/ai/model/mcp/registry/Icon.java#L166-L202","documentation":"Icon.MimeType.fromValue (a Jackson @JsonCreator) iterates all enum constants and throws IllegalArgumentException when the input string does not case-insensitively match any of: image/png, image/jpeg, image/jpg, image/svg+xml, image/webp. This fires during JSON deserialization of an Icon object with an unsupported mime type.","triggerScenarios":"Deserializing a JSON payload containing an icon with a mimeType like 'image/gif', 'image/x-icon', 'application/octet-stream', or a typo like 'image/png '. The match is case-insensitive but exact otherwise.","commonSituations":"A third-party MCP registry or external system sends an icon with a mime type not in the allowed set. A user uploads a .gif or .ico file and the client sends its mime type verbatim. Whitespace or encoding artifacts in the JSON value.","solutions":["Map or filter the incoming mime type to one of the five supported values before serialization.","If you control the icon source, convert images to PNG, JPEG, or WebP.","Trim whitespace from the value before deserialization.","Configure Jackson with a coercionConfig or custom deserializer to handle unknown mime types gracefully."],"exampleFix":"// before\n{ \"src\": \"icon.gif\", \"mimeType\": \"image/gif\" } // throws on parse\n\n// after\n{ \"src\": \"icon.png\", \"mimeType\": \"image/png\" } // ok\n\n// Or pre-process:\nString mt = rawMimeType != null ? rawMimeType.trim() : \"image/png\";\nif (!Set.of(\"image/png\",\"image/jpeg\",\"image/jpg\",\"image/svg+xml\",\"image/webp\")\n        .contains(mt.toLowerCase())) {\n    mt = \"image/png\";\n}","handlingStrategy":"validation","validationCode":"private static final Set<String> VALID_MIME_TYPES = Set.of(\n    \"image/png\", \"image/jpeg\", \"image/jpg\", \"image/svg+xml\", \"image/webp\");\n\nString normalized = rawMimeType == null ? null : rawMimeType.trim().toLowerCase();\nif (!VALID_MIME_TYPES.contains(normalized)) {\n    normalized = \"image/png\"; // or reject\n}","typeGuard":"public static boolean isValidMimeType(String value) {\n    if (value == null) return false;\n    String v = value.trim().toLowerCase();\n    return Set.of(\"image/png\",\"image/jpeg\",\"image/jpg\",\"image/svg+xml\",\"image/webp\").contains(v);\n}","tryCatchPattern":"try {\n    Icon icon = objectMapper.readValue(json, Icon.class);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Unknown mimeType\")) {\n        // normalize mimeType and retry, or return 400\n    }\n    throw e;\n}","preventionTips":["Validate mime types against the five supported values before serialization.","Convert unsupported image formats to PNG or WebP on upload.","Trim whitespace from JSON string values before deserialization."],"tags":["mcp","icon","jackson","enum","mime-type","deserialization"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}