OtterMind/Chat2DB · error · BusinessException

diff_error

diff_error

Error message

diff_error

What it means

Thrown by the diff() method's catch-all when any exception occurs during the Liquibase schema-diff workflow — building connections, initializing Liquibase Database objects, generating DiffResult, writing the changelog, or executing the Liquibase update. The original exception's message is passed as the first argument and the exception is chained. This is a wrapper error; the root cause is in the chained exception and the logged diff XML.

Source

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

            if (!FileUtil.exist(path)) {
                return "-- No differences. ";
            }
            configureLiquibaseTrackingTables(targetDatabase, databaseChangeLogTableName, databaseChangeLogLockTableName);
            String diffOutput = executeLiquibaseUpdate(targetDatabase, resourceAccessor, stringWriter);
            String filteredOutput = filter(diffOutput, target.getDbType(), databaseChangeLogTableName, databaseChangeLogLockTableName);

            if (StringUtils.isBlank(filteredOutput)) {
                log.error("diff error, filteredOutput is empty:" + source.getDatabaseName() + ":" + source.getSchemaName() + "," + target.getDatabaseName() + ":" + target.getSchemaName());
                log.error("diff xml:" + FileUtil.readUtf8String(filePath + File.separator + DIFF_FILE));
            }
            return filteredOutput;
        } catch (Exception e) {
            log.error("diff error", e);
            if (FileUtil.exist(filePath + File.separator + DIFF_FILE)) {
                log.error("diff xml:" + FileUtil.readUtf8String(filePath + File.separator + DIFF_FILE));
            }
            throw new BusinessException("diff_error", new Object[]{e.getMessage()}, e);
        } finally {
            try {
                FileUtil.del(filePath);
            } catch (Exception e) { // impl-contract: best-effort - cleanup failure must not hide the diff result or original failure.
                log.error("delete file error", e);
            }
        }
    }

    private ConnectInfo buildConnectInfo(DbConnectionDiffRequest param) {
        WorkspaceDataSource dataSource = workspaceDataSourceService.queryDisplayDataSourceById(param.getDataSourceId(), true);
        if (dataSource == null) {
            throw new BusinessException("datasource.not.found");
        }
        return connectionContextConverter.datasource2connectInfo(param, dataSource,
                JdbcUrlUtils.resetUrl(dataSource.getUrl(), dataSource.getType(), dataSource.getServiceType()));
    }

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Inspect the chained exception (BusinessException.getCause()) and the logged 'diff xml' for the root cause.
  2. Verify both source and target datasources are reachable and the dbTypes are supported by the bundled Liquibase.
  3. Ensure the target database user has CREATE TABLE permission (Liquibase creates tracking tables).
  4. Check that schemaName/databaseName in the request are valid for both connections.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    String changeLog = diffService.diff(sourceReq, targetReq);
} catch (BusinessException e) {
    if ("diff_error".equals(e.getCode())) {
        Throwable root = e.getCause();
        // inspect root (LiquibaseException / DatabaseException / IOException)
        // surface root.getMessage() to the user
    } else { throw e; }
}

Prevention

When it happens

Trigger: Any uncaught exception inside the try-with-resources block of diff(): LiquibaseException from DiffGeneratorFactory.compare, DatabaseException from DatabaseFactory initialization, IOException from changelog file I/O, SQL errors from Liquibase update execution, or parser errors during filter().

Common situations: Unsupported dialect for Liquibase diff; schema/catalog mismatch between source and target; connection authentication or network failure mid-diff; incompatible Liquibase version; permissions to create tracking tables missing on target.

Related errors


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