jd-opensource/joyagent-jdgenie · error · JdbcBizException
不支持的模型类型:
Error message
不支持的模型类型:
What it means
getFewShotSql builds the few-shot sampling SQL based on DataAgentModelConfig.getType(); it supports only 'table' (SELECT * FROM <content>) and 'sql' (content + LIMIT). Any other type value throws JdbcBizException with 不支持的模型类型:<type>, indicating the model config's content cannot be turned into a sample query.
Solutions
- Fix the DataAgentModelConfig.type value to 'table' or 'sql' for this model
- Extend getFewShotSql with a branch for the new type and how to sample from it
- Validate/normalize the type when saving model config so unsupported values are rejected at input time
- Log the model config id and type before throwing to identify the offending record
Example fix
// before
} else {
throw new JdbcBizException("不支持的模型类型:" + modelConfig.getType());
}
// after
} else if ("view".equalsIgnoreCase(modelConfig.getType())) {
return "SELECT * FROM " + modelConfig.getContent() + " LIMIT 10000";
} else {
throw new JdbcBizException("不支持的模型类型:" + modelConfig.getType() + ", modelId=" + modelConfig.getId());
} Defensive patterns
Strategy: validation
Validate before calling
if (modelConfig.getType() == null
|| !("table".equalsIgnoreCase(modelConfig.getType()) || "sql".equalsIgnoreCase(modelConfig.getType()))) {
throw new IllegalArgumentException("Model type must be 'table' or 'sql', got: " + modelConfig.getType());
} Type guard
boolean isSupportedModelType(DataAgentModelConfig cfg) {
return cfg != null && cfg.getType() != null
&& ("table".equalsIgnoreCase(cfg.getType()) || "sql".equalsIgnoreCase(cfg.getType()));
} Try / catch
try {
String fewShotSql = chatModelInfoService.buildFewShotSql(modelConfig, tableSchema);
} catch (JdbcBizException e) {
if (e.getMessage() != null && e.getMessage().startsWith("不支持的模型类型")) {
// reject or skip this model config with a clear admin-facing error
}
} Prevention
- Restrict the type field in the model-config UI to 'table' and 'sql'
- Validate type on saveModelInfo/config creation, not only at few-shot generation time
- When adding new model types, update getFewShotSql in the same change
- Log model id alongside the type in the exception for faster triage
When it happens
Trigger: Saving/syncing a model whose DataAgentModelConfig.type is neither 'table' nor 'sql' (case-insensitive) — e.g. type set to 'view', 'metric', an empty string, null, or a newly introduced config type not yet handled by getFewShotSql.
Common situations: Admin configures a new model type in the UI that the few-shot pipeline doesn't know; data migration introduces types like 'partition' or 'dataset'; type field left blank on model creation; newer config schema added without updating this branch.
Related errors
AI-assisted analysis of jd-opensource/joyagent-jdgenie@2417e0b8b6 (2026-09-08).
Data as JSON: /api/errors/8d5b0f8b7f20cbdf.
Report an issue: GitHub.
Appendix: source
Thrown at genie-backend/src/main/java/com/jd/genie/service/ChatModelInfoService.java:117
Set<String> values = columnValueMap.computeIfAbsent(key, k -> new HashSet<>());
if (values.size() > 11) {
continue;
}
//截取枚举最大300字符
stringValue = stringValue.substring(0, Math.min(300, stringValue.length()));
values.add(stringValue);
}
}
return columnValueMap;
}
private String getFewShotSql(DataAgentModelConfig modelConfig, List<TableColumn> tableSchema) {
if ("table".equalsIgnoreCase(modelConfig.getType())) {
return "SELECT * FROM " + modelConfig.getContent() + " LIMIT 10000";
} else if ("sql".equalsIgnoreCase(modelConfig.getType())) {
return modelConfig.getContent() + " LIMIT 10000";
} else {
throw new JdbcBizException("不支持的模型类型:" + modelConfig.getType());
}
}
@Transactional(rollbackFor = Exception.class)
public ChatModelInfo saveModelInfo(DataAgentModelConfig modelConfig, List<TableColumn> tableSchema, Map<String, Set<String>> fewShotMap) throws SQLException, ExecutionException, InterruptedException {
ChatModelInfo modelInfo = new ChatModelInfo();
String modelCode = modelConfig.getId();
modelInfo.setCode(modelCode);
modelInfo.setName(modelConfig.getName());
modelInfo.setContent(modelConfig.getContent());
modelInfo.setType(modelConfig.getType());
modelInfo.setUsePrompt(modelConfig.getRemark());
modelInfo.setBusinessPrompt(modelConfig.getBusinessPrompt());
save(modelInfo);
log.info("model info save success:{}", modelCode);
List<ChatModelSchema> chatModelSchemas = chatModelSchemaService.saveModelSchema(modelCode, modelConfig, tableSchema, fewShotMap);
log.info("model schema save success {},size:{}", modelCode, chatModelSchemas.size());
if (dataAgentConfig.getQdrantConfig().getEnable()) {View on GitHub (pinned to 2417e0b8b6)