{"record":{"id":"7ff2b7daade3ddbe","repo":"jd-opensource/joyagent-jdgenie","slug":"error-7ff2b7","errorCode":null,"errorMessage":"不支持的数据源类型:","messagePattern":"不支持的数据源类型:","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/data/jdbc/dialect/DialectEnum.java","lineNumber":33,"sourceCode":"    private final String urlEndWith;\n\n    DialectEnum(String name, String urlPrefix, String suffixDelimiter, String urlEndWith) {\n        this.name = name;\n        this.urlPrefix = urlPrefix;\n        this.suffixDelimiter = suffixDelimiter;\n        this.urlEndWith = urlEndWith;\n    }\n\n    public static DialectEnum of(String dialectName) {\n        DialectEnum[] dialectEnums = DialectEnum.class.getEnumConstants();\n\n        for (DialectEnum dialectEnum : dialectEnums) {\n            if (StringUtils.equalsIgnoreCase(dialectName, dialectEnum.name)) {\n                return dialectEnum;\n            }\n        }\n\n        throw new IllegalArgumentException(\"不支持的数据源类型:\" + dialectName);\n    }\n\n}\n","sourceCodeStart":15,"sourceCodeEnd":37,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/data/jdbc/dialect/DialectEnum.java#L15-L37","documentation":"DialectEnum.of parses a dialect name string into the DialectEnum by case-insensitive name match. If no enum constant matches, it throws IllegalArgumentException '不支持的数据源类型:<dialectName>'. This is the entry-point validation that a dialect string is one of the supported database types.","triggerScenarios":"Calling DialectEnum.of(name) with a name not in the enum (e.g. 'postgres', 'sqlite', empty string, or a misspelling like 'myslq').","commonSituations":"Typo or wrong casing in a config file, user-supplied datasource type not whitelisted, or a newly added database type missing from the enum.","solutions":["Use an exact supported dialect name (match the enum constants, matching is case-insensitive).","Check the config value for typos/whitespace and trim it.","Add the new database type to DialectEnum and to JdbcConnectionPoolFactory's switch.","Catch IllegalArgumentException at the config-loading boundary and surface a friendly message.","Pre-validate with a Set<String> of allowed dialect names."],"exampleFix":"// before\nDialectEnum.of(\"postgres\"); // throws IllegalArgumentException\n// after\nDialectEnum.of(\"MYSQL\"); // valid enum name\n// or add to the enum: POSTGRESQL(\"postgresql\", ...)","handlingStrategy":"validation","validationCode":"// Java: validate dialect name before DialectEnum.of\nString name = rawName == null ? \"\" : rawName.trim();\nSet<String> ALLOWED = Arrays.stream(DialectEnum.values())\n    .map(DialectEnum::getName).collect(Collectors.toSet());\nif (!ALLOWED.stream().anyMatch(n -> n.equalsIgnoreCase(name))) {\n    throw new IllegalArgumentException(\"unsupported dialect: \" + rawName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    DialectEnum dialect = DialectEnum.of(rawName);\n} catch (IllegalArgumentException e) {\n    log.error(\"Bad datasource type '{}': allowed={}\", rawName, allowedNames, e);\n    // fall back to default dialect or reject config\n}","preventionTips":["Trim and normalize dialect strings at config load.","Keep allowed dialects defined in one place (the enum) and validate early.","Catch IllegalArgumentException at the config boundary with a friendly message.","When adding a database type, update the enum AND the pool factory together."],"tags":["enum","dialect","validation","config"],"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"}