jd-opensource/joyagent-jdgenie · error · RuntimeException

不支持的模型类型

Error message

不支持的模型类型

What it means

ColumnValueSyncService.getTableName() resolves the physical table name (or a derived subquery alias) from a ChatModelInfo's type. Only 'table' and 'sql' are accepted; any other type throws this RuntimeException, so column-value synchronization cannot proceed for that model.

Solutions

  1. Set the ChatModelInfo type to 'table' or 'sql' before syncing
  2. Query the model record and correct its type field
  3. Align type values with the two branches handled here; log the model id in the message for diagnosis

Example fix

// before
throw new RuntimeException("不支持的模型类型" + modelInfo.getType());
// after
throw new RuntimeException("不支持的模型类型[" + modelInfo.getType() + "], modelId=" + modelInfo.getId() + ", 仅支持 table/sql");
Defensive patterns

Strategy: validation

Validate before calling

String type = modelInfo.getType();
if (!"table".equalsIgnoreCase(type) && !"sql".equalsIgnoreCase(type)) {
    throw new IllegalArgumentException("unsupported model type: " + type);
}
String tableName = syncService.getTableName(modelInfo);

Try / catch

try {
    String t = syncService.getTableName(modelInfo);
} catch (RuntimeException e) {
    log.warn("skip sync, bad model type: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling getTableName() (via tableName) or syncColumnValueBatch flows with a ChatModelInfo whose type is not 'table' or 'sql'.

Common situations: ChatModelInfo records seeded with an unexpected type in the model management UI/DB; type field left null; inconsistent types between ChatModelInfo (this service) and DataAgentModelConfig (ChatModelInfoService).

Related errors


AI-assisted analysis of jd-opensource/joyagent-jdgenie@2417e0b8b6 (2026-09-08). Data as JSON: /api/errors/d6caa3d5c4dc3204. Report an issue: GitHub.

Appendix: source

Thrown at genie-backend/src/main/java/com/jd/genie/service/ColumnValueSyncService.java:54

    @Autowired
    JdbcDataProvider jdbcDataProvider;

    public void initColumnValueIndex() {
        if (ESUtil.isExistsIndex(dataAgentEsClient, DataAgentConstants.COLUMN_VALUE_ES_INDEX)) {
            log.info("es index 已存在,无需创建");
            return;
        }
        log.info("es index 不存在,开始创建");
        ESUtil.createIndex(dataAgentEsClient, DataAgentConstants.COLUMN_VALUE_ES_INDEX, DataAgentConstants.COLUMN_VALUE_ES_MAPPING);
    }

    public String getTableName(ChatModelInfo modelInfo) {
        if ("table".equalsIgnoreCase(modelInfo.getType())) {
            return modelInfo.getContent();
        } else if ("sql".equalsIgnoreCase(modelInfo.getType())) {
            return "(" + modelInfo.getContent() + ") t";
        } else {
            throw new RuntimeException("不支持的模型类型" + modelInfo.getType());
        }
    }

    public void syncColumnValueBatch(ChatModelInfo modelInfo, List<ChatModelSchema> chatModelSchemas) throws SQLException {
        if (CollectionUtils.isEmpty(chatModelSchemas)) {
            log.info("没有需要同步的字段值");
            return;
        }
        for (ChatModelSchema chatModelSchema : chatModelSchemas) {
            syncColumnValue(modelInfo, chatModelSchema);
        }
    }


    public void syncColumnValue(ChatModelInfo modelInfo, ChatModelSchema column) throws SQLException {
        String tableName = getTableName(modelInfo);
        String valueSql = String.format("select %s as `value` FROM %s WHERE %s IS NOT NULL GROUP BY %s Limit  10000", column.getColumnId(), tableName, column.getColumnId(), column.getColumnId());
        JdbcQueryRequest jdbcQueryRequest = new JdbcQueryRequest();

View on GitHub (pinned to 2417e0b8b6)