OtterMind/Chat2DB · error · BusinessException

copyInValues.invalidSourceType

copyInValues.invalidSourceType

Error message

copyInValues.invalidSourceType

What it means

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.

Source

Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbDlTemplateServiceImpl.java:185

    public String copySelectResult(DbSelectResultUpdateRequest param) {

        ISqlBuilder sqlBuilder = Chat2DBContext.getSqlBuilder();
        QueryResponse queryResult = commandConverter.updateSelectResult2query(param);
        return sqlBuilder.dml().buildCopyByQueryResult(queryResult);
    }

    @Override
    public String copyInValues(DbCopyInValuesRequest param) {
        ISqlBuilder sqlBuilder = Chat2DBContext.getSqlBuilder();
        if (!(sqlBuilder instanceof DefaultSqlBuilder)) {
            throw new BusinessException("copyInValues.unsupportedDataSource");
        }
        DefaultSqlBuilder defaultSqlBuilder = (DefaultSqlBuilder) sqlBuilder;
        if (StringUtils.equalsIgnoreCase(DbCopyInValuesRequest.SOURCE_TYPE_EXTERNAL_TEXT, param.getSourceType())) {
            return defaultSqlBuilder.copyExternalTextInValues(param.getExternalValues());
        }
        if (!StringUtils.equalsIgnoreCase(DbCopyInValuesRequest.SOURCE_TYPE_RESULT_SET, param.getSourceType())) {
            throw new BusinessException("copyInValues.invalidSourceType");
        }
        QueryResponse queryResult = commandConverter.copyInValues2query(param);
        return defaultSqlBuilder.copyInValuesByQuery(queryResult);
    }

    @Override
    public ExecuteResponse validate(DbSqlValidateRequest param) {
        String sql = param.getSql();
        ICommandExecutor executor = Chat2DBContext.getDbMetaData().getCommandExecutor();
        if (StringUtils.isEmpty(sql)) {
            return ExecuteResponse.builder().success(true).build();
        }
        String type = Chat2DBContext.getConnectInfo().getDbType();
        List<SimpleSqlStatement> statements = new ArrayList<>();
        try {
            List<ai.chat2db.community.domain.api.model.parser.statement.Statement> antlrSqlStatements = DefaultSqlSyntaxHandler.simpleParserStatements(sql, type);
            if (CollectionUtils.isNotEmpty(antlrSqlStatements)) {
                statements = antlrSqlStatements.stream().map(statement -> {

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Set sourceType to exactly one of DbCopyInValuesRequest.SOURCE_TYPE_EXTERNAL_TEXT or SOURCE_TYPE_RESULT_SET.
  2. Validate the sourceType in the frontend before submitting.
  3. If a new source type is needed, add a constant and a code branch for it.

Example fix

// before
copyInValues(DbCopyInValuesRequest.builder()
    .sourceType("csv")  // not recognized
    .build());

// after
copyInValues(DbCopyInValuesRequest.builder()
    .sourceType(DbCopyInValuesRequest.SOURCE_TYPE_EXTERNAL_TEXT)
    .externalValues(csvText)
    .build());
Defensive patterns

Strategy: validation

Validate before calling

boolean valid = DbCopyInValuesRequest.SOURCE_TYPE_EXTERNAL_TEXT.equalsIgnoreCase(sourceType)
        || DbCopyInValuesRequest.SOURCE_TYPE_RESULT_SET.equalsIgnoreCase(sourceType);
if (!valid) { /* block / correct before calling copyInValues */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/afff824704900512. Report an issue: GitHub.