jd-opensource/joyagent-jdgenie · error · IllegalArgumentException
不支持的数据源类型:
Error message
不支持的数据源类型:
What it means
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.
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.
Example fix
// before
DialectEnum.of("postgres"); // throws IllegalArgumentException
// after
DialectEnum.of("MYSQL"); // valid enum name
// or add to the enum: POSTGRESQL("postgresql", ...) Defensive patterns
Strategy: validation
Validate before calling
// Java: validate dialect name before DialectEnum.of
String name = rawName == null ? "" : rawName.trim();
Set<String> ALLOWED = Arrays.stream(DialectEnum.values())
.map(DialectEnum::getName).collect(Collectors.toSet());
if (!ALLOWED.stream().anyMatch(n -> n.equalsIgnoreCase(name))) {
throw new IllegalArgumentException("unsupported dialect: " + rawName);
} Try / catch
try {
DialectEnum dialect = DialectEnum.of(rawName);
} catch (IllegalArgumentException e) {
log.error("Bad datasource type '{}': allowed={}", rawName, allowedNames, e);
// fall back to default dialect or reject config
} Prevention
- 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.
When it happens
Trigger: Calling DialectEnum.of(name) with a name not in the enum (e.g. 'postgres', 'sqlite', empty string, or a misspelling like 'myslq').
Common situations: Typo or wrong casing in a config file, user-supplied datasource type not whitelisted, or a newly added database type missing from the enum.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Invalid tool_choice: " + toolChoice
- 服务器URL不能为空且必须是字符串类型
- step_index is required for mark_step command
- Could not find any jdbc dialect factory that can handled
- 未找到支持 的JdbcDialectFactory实现类
AI-assisted analysis of jd-opensource/joyagent-jdgenie@2417e0b8b6 (2026-09-08).
Data as JSON: /api/errors/7ff2b7daade3ddbe.
Report an issue: GitHub.
Appendix: source
Thrown at genie-backend/src/main/java/com/jd/genie/data/jdbc/dialect/DialectEnum.java:33
private final String urlEndWith;
DialectEnum(String name, String urlPrefix, String suffixDelimiter, String urlEndWith) {
this.name = name;
this.urlPrefix = urlPrefix;
this.suffixDelimiter = suffixDelimiter;
this.urlEndWith = urlEndWith;
}
public static DialectEnum of(String dialectName) {
DialectEnum[] dialectEnums = DialectEnum.class.getEnumConstants();
for (DialectEnum dialectEnum : dialectEnums) {
if (StringUtils.equalsIgnoreCase(dialectName, dialectEnum.name)) {
return dialectEnum;
}
}
throw new IllegalArgumentException("不支持的数据源类型:" + dialectName);
}
}
View on GitHub (pinned to 2417e0b8b6)