{"record":{"id":"ae649c1e487d9346","repo":"jd-opensource/joyagent-jdgenie","slug":"error-ae649c","errorCode":null,"errorMessage":"不支持类型","messagePattern":"不支持类型","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/model/enums/EventTypeEnum.java","lineNumber":33,"sourceCode":"     * 用户可输入\n     */\n    READY,\n    /**\n     * 异常\n     */\n    ERROR,\n    /**\n     * debug信息\n     */\n    DEBUG;\n\n    public static EventTypeEnum of(String type) {\n        for (EventTypeEnum authType : EventTypeEnum.class.getEnumConstants()) {\n            if (StringUtils.equalsIgnoreCase(type, authType.name())) {\n                return authType;\n            }\n        }\n        throw new IllegalArgumentException(\"不支持类型\");\n    }\n}\n","sourceCodeStart":15,"sourceCodeEnd":36,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/model/enums/EventTypeEnum.java#L15-L36","documentation":"EventTypeEnum.of(type) iterates all enum constants and returns the one whose name case-insensitively matches; if no constant matches, it throws an IllegalArgumentException with the generic message 不支持类型 (unsupported type). The thrown message does not even include the offending value, making diagnosis harder.","triggerScenarios":"Calling EventTypeEnum.of with a type string that is not exactly (case-insensitive) one of the enum constant names — e.g. misspelled names, different naming conventions (kebab-case vs camelCase), localized Chinese labels, or legacy/removed enum values stored in old data.","commonSituations":"Old records in the database contain event type strings that were renamed or removed from the enum; frontend sends a display label instead of the enum name; API consumers use different casing/format than the enum constants.","solutions":["Log or include the offending type string in the exception message to identify the bad value","Normalize the input (trim, remove spaces/dashes) before calling of()","Add the missing constant to EventTypeEnum if the type is a legitimate new value","Use a from-value mapping that tolerates aliases instead of exact name matching"],"exampleFix":"// before\nEventTypeEnum eventType = EventTypeEnum.of(request.getType()); // IllegalArgumentException: 不支持类型\n// after\nString normalized = request.getType() == null ? null : request.getType().trim().replace(\"-\", \"_\");\nEventTypeEnum eventType = EventTypeEnum.of(normalized); // or add try/catch with a clear message","handlingStrategy":"try-catch","validationCode":"boolean known = java.util.Arrays.stream(EventTypeEnum.class.getEnumConstants())\n    .anyMatch(e -> e.name().equalsIgnoreCase(type));\nif (!known) {\n    throw new IllegalArgumentException(\"Unknown event type: \" + type);\n}","typeGuard":"java.util.Optional<EventTypeEnum> tryOf(String type) {\n    return java.util.Arrays.stream(EventTypeEnum.class.getEnumConstants())\n        .filter(e -> org.apache.commons.lang3.StringUtils.equalsIgnoreCase(type, e.name()))\n        .findFirst();\n}","tryCatchPattern":"try {\n    EventTypeEnum t = EventTypeEnum.of(type);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Unknown event type '{}', using default\", type);\n    EventTypeEnum t = EventTypeEnum.DEFAULT; // or reject the request with a clear message\n}","preventionTips":["Trim and normalize the type string before mapping to the enum","Use a tolerant lookup returning Optional instead of throwing","Keep stored/legacy type values in sync with enum constant names","Improve the exception message to include the offending value"],"tags":["enum","java","invalid-input"],"backgroundTag":"invalid-enum-value","analyzedSha":"2417e0b8b636d941ad5fb14c59b20dddfef5375d","analyzedAt":"2026-09-08T11:28:19.414Z","contentChangedAt":"2026-09-08T11:28:19.414Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}