{"record":{"id":"afff824704900512","repo":"OtterMind/Chat2DB","slug":"copyinvalues-invalidsourcetype","errorCode":"copyInValues.invalidSourceType","errorMessage":"copyInValues.invalidSourceType","messagePattern":"copyInValues\\.invalidSourceType","errorType":"validation","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbDlTemplateServiceImpl.java","lineNumber":185,"sourceCode":"    public String copySelectResult(DbSelectResultUpdateRequest param) {\n\n        ISqlBuilder sqlBuilder = Chat2DBContext.getSqlBuilder();\n        QueryResponse queryResult = commandConverter.updateSelectResult2query(param);\n        return sqlBuilder.dml().buildCopyByQueryResult(queryResult);\n    }\n\n    @Override\n    public String copyInValues(DbCopyInValuesRequest param) {\n        ISqlBuilder sqlBuilder = Chat2DBContext.getSqlBuilder();\n        if (!(sqlBuilder instanceof DefaultSqlBuilder)) {\n            throw new BusinessException(\"copyInValues.unsupportedDataSource\");\n        }\n        DefaultSqlBuilder defaultSqlBuilder = (DefaultSqlBuilder) sqlBuilder;\n        if (StringUtils.equalsIgnoreCase(DbCopyInValuesRequest.SOURCE_TYPE_EXTERNAL_TEXT, param.getSourceType())) {\n            return defaultSqlBuilder.copyExternalTextInValues(param.getExternalValues());\n        }\n        if (!StringUtils.equalsIgnoreCase(DbCopyInValuesRequest.SOURCE_TYPE_RESULT_SET, param.getSourceType())) {\n            throw new BusinessException(\"copyInValues.invalidSourceType\");\n        }\n        QueryResponse queryResult = commandConverter.copyInValues2query(param);\n        return defaultSqlBuilder.copyInValuesByQuery(queryResult);\n    }\n\n    @Override\n    public ExecuteResponse validate(DbSqlValidateRequest param) {\n        String sql = param.getSql();\n        ICommandExecutor executor = Chat2DBContext.getDbMetaData().getCommandExecutor();\n        if (StringUtils.isEmpty(sql)) {\n            return ExecuteResponse.builder().success(true).build();\n        }\n        String type = Chat2DBContext.getConnectInfo().getDbType();\n        List<SimpleSqlStatement> statements = new ArrayList<>();\n        try {\n            List<ai.chat2db.community.domain.api.model.parser.statement.Statement> antlrSqlStatements = DefaultSqlSyntaxHandler.simpleParserStatements(sql, type);\n            if (CollectionUtils.isNotEmpty(antlrSqlStatements)) {\n                statements = antlrSqlStatements.stream().map(statement -> {","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbDlTemplateServiceImpl.java#L167-L203","documentation":"Thrown by copyInValues when param.getSourceType() is neither SOURCE_TYPE_EXTERNAL_TEXT nor SOURCE_TYPE_RESULT_SET (case-insensitive). The method only recognizes two source types for the values to copy in; any other value is rejected. This is an input-validation error on the request enum.","triggerScenarios":"Calling copyInValues with a sourceType that is not equal (ignoreCase) to the EXTERNAL_TEXT or RESULT_SET constant. If sourceType is null, equalsIgnoreCase returns false and this error fires.","commonSituations":"Frontend sends a null or unrecognized sourceType string; a new source type was added to the UI but not to the backend constants; typo in the sourceType value.","solutions":["Set sourceType to exactly one of DbCopyInValuesRequest.SOURCE_TYPE_EXTERNAL_TEXT or SOURCE_TYPE_RESULT_SET.","Validate the sourceType in the frontend before submitting.","If a new source type is needed, add a constant and a code branch for it."],"exampleFix":"// before\ncopyInValues(DbCopyInValuesRequest.builder()\n    .sourceType(\"csv\")  // not recognized\n    .build());\n\n// after\ncopyInValues(DbCopyInValuesRequest.builder()\n    .sourceType(DbCopyInValuesRequest.SOURCE_TYPE_EXTERNAL_TEXT)\n    .externalValues(csvText)\n    .build());","handlingStrategy":"validation","validationCode":"boolean valid = DbCopyInValuesRequest.SOURCE_TYPE_EXTERNAL_TEXT.equalsIgnoreCase(sourceType)\n        || DbCopyInValuesRequest.SOURCE_TYPE_RESULT_SET.equalsIgnoreCase(sourceType);\nif (!valid) { /* block / correct before calling copyInValues */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the declared constants for sourceType, never raw strings.","Validate sourceType client-side before submitting the request."],"tags":["copy-in-values","validation","invalid-input"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}