{"record":{"id":"8d5b0f8b7f20cbdf","repo":"jd-opensource/joyagent-jdgenie","slug":"error-8d5b0f","errorCode":null,"errorMessage":"不支持的模型类型：","messagePattern":"不支持的模型类型：","errorType":"exception","errorClass":"JdbcBizException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/service/ChatModelInfoService.java","lineNumber":117,"sourceCode":"                Set<String> values = columnValueMap.computeIfAbsent(key, k -> new HashSet<>());\n                if (values.size() > 11) {\n                    continue;\n                }\n                //截取枚举最大300字符\n                stringValue = stringValue.substring(0, Math.min(300, stringValue.length()));\n                values.add(stringValue);\n            }\n        }\n        return columnValueMap;\n    }\n\n    private String getFewShotSql(DataAgentModelConfig modelConfig, List<TableColumn> tableSchema) {\n        if (\"table\".equalsIgnoreCase(modelConfig.getType())) {\n            return \"SELECT * FROM \" + modelConfig.getContent() + \" LIMIT 10000\";\n        } else if (\"sql\".equalsIgnoreCase(modelConfig.getType())) {\n            return modelConfig.getContent() + \" LIMIT 10000\";\n        } else {\n            throw new JdbcBizException(\"不支持的模型类型：\" + modelConfig.getType());\n        }\n    }\n\n    @Transactional(rollbackFor = Exception.class)\n    public ChatModelInfo saveModelInfo(DataAgentModelConfig modelConfig, List<TableColumn> tableSchema, Map<String, Set<String>> fewShotMap) throws SQLException, ExecutionException, InterruptedException {\n        ChatModelInfo modelInfo = new ChatModelInfo();\n        String modelCode = modelConfig.getId();\n        modelInfo.setCode(modelCode);\n        modelInfo.setName(modelConfig.getName());\n        modelInfo.setContent(modelConfig.getContent());\n        modelInfo.setType(modelConfig.getType());\n        modelInfo.setUsePrompt(modelConfig.getRemark());\n        modelInfo.setBusinessPrompt(modelConfig.getBusinessPrompt());\n        save(modelInfo);\n        log.info(\"model info save success:{}\", modelCode);\n        List<ChatModelSchema> chatModelSchemas = chatModelSchemaService.saveModelSchema(modelCode, modelConfig, tableSchema, fewShotMap);\n        log.info(\"model schema save success {},size:{}\", modelCode, chatModelSchemas.size());\n        if (dataAgentConfig.getQdrantConfig().getEnable()) {","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/service/ChatModelInfoService.java#L99-L135","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n} else {\n    throw new JdbcBizException(\"不支持的模型类型：\" + modelConfig.getType());\n}\n// after\n} else if (\"view\".equalsIgnoreCase(modelConfig.getType())) {\n    return \"SELECT * FROM \" + modelConfig.getContent() + \" LIMIT 10000\";\n} else {\n    throw new JdbcBizException(\"不支持的模型类型：\" + modelConfig.getType() + \", modelId=\" + modelConfig.getId());\n}","handlingStrategy":"validation","validationCode":"if (modelConfig.getType() == null\n        || !(\"table\".equalsIgnoreCase(modelConfig.getType()) || \"sql\".equalsIgnoreCase(modelConfig.getType()))) {\n    throw new IllegalArgumentException(\"Model type must be 'table' or 'sql', got: \" + modelConfig.getType());\n}","typeGuard":"boolean isSupportedModelType(DataAgentModelConfig cfg) {\n    return cfg != null && cfg.getType() != null\n        && (\"table\".equalsIgnoreCase(cfg.getType()) || \"sql\".equalsIgnoreCase(cfg.getType()));\n}","tryCatchPattern":"try {\n    String fewShotSql = chatModelInfoService.buildFewShotSql(modelConfig, tableSchema);\n} catch (JdbcBizException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"不支持的模型类型\")) {\n        // reject or skip this model config with a clear admin-facing error\n    }\n}","preventionTips":["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"],"tags":["configuration","sql","unsupported-type"],"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"}