OtterMind/Chat2DB · error · ParamBusinessException

exportType

exportType

Error message

exportType

What it means

Thrown by DbDmlExportServiceImpl.prepareExport after EasyEnumUtils.getEnum(ExportTypeEnum.class, param.getExportType()) returns null, meaning the supplied export type does not match any ExportTypeEnum (CSV/EXCEL/INSERT/SQL). It is a ParamBusinessException, so the resolved code is 'common.paramDetailError' with arg 'exportType', producing 'The parameter: exportType is incorrect'. This is an input-contract failure, not a runtime fault.

Solutions

  1. Send one of the valid ExportTypeEnum values (verify the enum constants in the current build) for exportType.
  2. Validate exportType on the client/adapter before calling prepareExport and surface a clear message.
  3. If a new export format is intended, extend ExportTypeEnum and the matching export branch rather than passing an unknown string.

Example fix

// before
param.setExportType("PDF"); // not an ExportTypeEnum
service.prepareExport(param); // -> ParamBusinessException

// after
param.setExportType(ExportTypeEnum.EXCEL.name());
service.prepareExport(param);
Defensive patterns

Strategy: validation

Validate before calling

ExportTypeEnum t = EasyEnumUtils.getEnum(ExportTypeEnum.class, param.getExportType());
if (t == null) {
    throw new ParamBusinessException("exportType");
}
service.prepareExport(param);

Type guard

// Narrow the export type before export
boolean isKnownExportType(String v) {
    if (v == null) return false;
    for (ExportTypeEnum e : ExportTypeEnum.values()) {
        if (e.name().equals(v)) return true;
    }
    return false;
}

Prevention

When it happens

Trigger: Export endpoint invoked with exportType null, blank, or a value not present in ExportTypeEnum (typo, legacy code, out-of-range ordinal). prepareExport is the entry point that builds DbDmlExportPlan, so an invalid type aborts planning before any SQL is resolved.

Common situations: Frontend dropdown defaulting to '' and sent through; a newer client sending a format the server build does not recognize; test fixtures using a numeric/string value that does not round-trip through the enum.

Related errors


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

Appendix: source

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

    @Override
    public String resolveTableName(String sql, String databaseName, String schemaName) {
        DbType dbType = currentDruidDbType();
        if (dbType == null) {
            return StringUtils.join(Lists.newArrayList(databaseName, schemaName), "_");
        }
        try {
            return SqlUtils.getTableName(sql, dbType);
        } catch (Exception ignored) { // impl-contract: fallback - export file naming falls back to database/schema when SQL parsing fails.
            return StringUtils.join(Lists.newArrayList(databaseName, schemaName), "_");
        }
    }

    @Override
    public DbDmlExportPlan prepareExport(DbDmlExportRequest param) {
        String sql = resolveSql(param);
        ExportTypeEnum exportType = EasyEnumUtils.getEnum(ExportTypeEnum.class, param.getExportType());
        if (exportType == null) {
            throw new ParamBusinessException("exportType");
        }
        String tableName = resolveTableName(sql, param.getDatabaseName(), param.getSchemaName());
        param.setSql(sql);
        return DbDmlExportPlan.builder()
                .fileName(buildFileName(tableName))
                .exportType(exportType)
                .exportRequest(param)
                .build();
    }

    @Override
    public void export(DbDmlExportRequest param, OutputStream outputStream) throws IOException {
        ExportTypeEnum exportType = ExportTypeEnum.from(param.getExportType());
        if (ExportTypeEnum.CSV == exportType) {
            exportCsv(param.getSql(), outputStream, param.getResultSetId());
            return;
        }
        if (ExportTypeEnum.EXCEL == exportType) {

View on GitHub (pinned to 5ee1e990e7)