{"record":{"id":"e0f76b0d23ba50d3","repo":"jd-opensource/joyagent-jdgenie","slug":"error-e0f76b","errorCode":null,"errorMessage":"不支持的模型类型","messagePattern":"不支持的模型类型","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/service/Nl2SqlService.java","lineNumber":120,"sourceCode":"        }\n        if (CollectionUtils.isEmpty(nl2SQLResult.getData())) {\n            throw new RuntimeException(\"nl2sql返回为空\");\n        }\n        nl2SQLResult.setRootQuery(request.getQuery());\n        for (NL2SQLResult.NL2SQLData nl2SQLData : nl2SQLResult.getData()) {\n            String prettySql = replaceFirstMatchedOrThrow(nl2SQLData.getNl2sql(), request.getModelCodeList());\n            nl2SQLData.setNl2sql(prettySql);\n        }\n        return queryData(request, nl2SQLResult);\n    }\n\n    public String getTableName(ChatModelInfoDto modelInfo) {\n        if (\"table\".equalsIgnoreCase(modelInfo.getType())) {\n            return modelInfo.getContent();\n        } else if (\"sql\".equalsIgnoreCase(modelInfo.getType())) {\n            return \"(\" + modelInfo.getContent() + \") t\";\n        } else {\n            throw new RuntimeException(\"不支持的模型类型\" + modelInfo.getType());\n        }\n    }\n\n    public List<ChatQueryData> queryData(NL2SQLReq request, NL2SQLResult nl2SQLResult) throws Exception {\n        List<NL2SQLResult.NL2SQLData> data = nl2SQLResult.getData();\n        List<ChatQueryData> dataList = new ArrayList<>();\n        List<ChatModelInfoDto> schemaInfo = request.getSchemaInfo();\n        Map<String, ChatModelInfoDto> modelMap = schemaInfo.stream().collect(Collectors.toMap(ChatModelInfoDto::getModelCode, v -> v));\n        for (NL2SQLResult.NL2SQLData nl2SQLData : data) {\n            SqlModel sqlModel = SqlParserUtils.parseSelectSql(nl2SQLData.getNl2sql(), dataAgentConfig.getDbConfig().getType());\n            String modelCode = sqlModel.getFromTable().getTableName();\n            ChatModelInfoDto modelInfo = modelMap.get(modelCode);\n            if (modelInfo == null) {\n                throw new RuntimeException(\"modelCode:\" + modelCode + \"不存在\");\n            }\n            Map<String, ChatSchemaDto> columnMap = modelInfo.getSchemaList().stream().collect(Collectors.toMap(ChatSchemaDto::getColumnId, t -> t));\n            List<ChatQueryColumn> chatQueryColumns = parseColumns(sqlModel, columnMap);\n            List<ChatQueryFilter> chatQueryFilters = parseFilters(sqlModel, columnMap);","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/service/Nl2SqlService.java#L102-L138","documentation":"Nl2SqlService.getTableName(ChatModelInfoDto) maps a model type to a table reference for querying: 'table' yields the content as-is, 'sql' wraps content as a subquery '(content) t'. Any other type throws this RuntimeException, blocking queryData execution for that model.","triggerScenarios":"queryData() processing NL2SQLResult data referencing a ChatModelInfoDto whose type is neither 'table' nor 'sql'.","commonSituations":"Model metadata maintained with unsupported type values; drift between the model registry and the two types this service supports; type field null in the DTO.","solutions":["Set the ChatModelInfoDto type to 'table' or 'sql'","Correct the model record in the model management storage before running queries","Include the model id/type in the exception message to speed diagnosis"],"exampleFix":"// before\nthrow new RuntimeException(\"不支持的模型类型\" + modelInfo.getType());\n// after\nthrow new RuntimeException(\"不支持的模型类型[\" + modelInfo.getType() + \"], 仅支持 table/sql\");","handlingStrategy":"validation","validationCode":"String type = dto.getType();\nif (!\"table\".equalsIgnoreCase(type) && !\"sql\".equalsIgnoreCase(type)) {\n    throw new IllegalArgumentException(\"unsupported model type: \" + type);\n}\nString tableName = nl2SqlService.getTableName(dto);","typeGuard":null,"tryCatchPattern":"try {\n    String t = nl2SqlService.getTableName(dto);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"不支持的模型类型\")) {\n        log.error(\"bad model type for query: {}\", e.getMessage());\n        // skip this model or fail the query with a clear message\n    }\n    throw e;\n}","preventionTips":["Enforce the table/sql type enum when creating model DTOs","Share one type constant/enum across services","Validate types before building NL2SQL requests"],"tags":["configuration","unsupported-type","query"],"backgroundTag":"unsupported-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"}