OtterMind/Chat2DB · error · BusinessException

datasource.not.found

datasource.not.found

Error message

datasource.not.found

What it means

Thrown by buildConnectInfo when workspaceDataSourceService.queryDisplayDataSourceById(param.getDataSourceId(), true) returns null — meaning no WorkspaceDataSource exists for the given dataSourceId (for either the source or target side of the diff). This is a lookup failure on the stored datasource configuration, not a connection failure.

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:112

        } 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()));
    }

    private Database initializeDatabase(Connection conn, ConnectInfo connectInfo) throws DatabaseException {
        Database database = DatabaseFactory.getInstance()
                .findCorrectDatabaseImplementation(new JdbcConnection(conn));
        if (StringUtils.isNotBlank(connectInfo.getSchemaName())) {
            database.setDefaultSchemaName(connectInfo.getSchemaName());
        }
        if (StringUtils.isNotBlank(connectInfo.getDatabaseName())) {
            database.setDefaultCatalogName(connectInfo.getDatabaseName());
        }
        return database;
    }

    private DiffResult generateDiff(Database sourceDatabase, Database targetDatabase) throws LiquibaseException {

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Verify the dataSourceId exists in the workspace datasource table before invoking diff.
  2. Refresh the datasource picker in the UI and reselect both source and target.
  3. Check that the datasource belongs to the current workspace context.
Defensive patterns

Strategy: validation

Validate before calling

WorkspaceDataSource ds = workspaceDataSourceService.queryDisplayDataSourceById(dataSourceId, true);
if (ds == null) {
    // do not call diff; prompt user to reselect datasource
}

Prevention

When it happens

Trigger: Calling diff() with a DbConnectionDiffRequest whose dataSourceId does not match any stored WorkspaceDataSource record. Fires for either the source or target parameter since buildConnectInfo is called for both.

Common situations: Datasource was deleted between UI selection and diff execution; dataSourceId is 0/null/default from an unpopulated form; the datasource belongs to a different workspace/tenant than the query scope.

Related errors


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