{"record":{"id":"daf26ff3c363b20a","repo":"OtterMind/Chat2DB","slug":"datasource-not-found-daf26f","errorCode":"datasource.not.found","errorMessage":"datasource.not.found","messagePattern":"datasource\\.not\\.found","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/DbDiffServiceImpl.java","lineNumber":112,"sourceCode":"        } catch (Exception e) {\n            log.error(\"diff error\", e);\n            if (FileUtil.exist(filePath + File.separator + DIFF_FILE)) {\n                log.error(\"diff xml:\" + FileUtil.readUtf8String(filePath + File.separator + DIFF_FILE));\n            }\n            throw new BusinessException(\"diff_error\", new Object[]{e.getMessage()}, e);\n        } finally {\n            try {\n                FileUtil.del(filePath);\n            } catch (Exception e) { // impl-contract: best-effort - cleanup failure must not hide the diff result or original failure.\n                log.error(\"delete file error\", e);\n            }\n        }\n    }\n\n    private ConnectInfo buildConnectInfo(DbConnectionDiffRequest param) {\n        WorkspaceDataSource dataSource = workspaceDataSourceService.queryDisplayDataSourceById(param.getDataSourceId(), true);\n        if (dataSource == null) {\n            throw new BusinessException(\"datasource.not.found\");\n        }\n        return connectionContextConverter.datasource2connectInfo(param, dataSource,\n                JdbcUrlUtils.resetUrl(dataSource.getUrl(), dataSource.getType(), dataSource.getServiceType()));\n    }\n\n    private Database initializeDatabase(Connection conn, ConnectInfo connectInfo) throws DatabaseException {\n        Database database = DatabaseFactory.getInstance()\n                .findCorrectDatabaseImplementation(new JdbcConnection(conn));\n        if (StringUtils.isNotBlank(connectInfo.getSchemaName())) {\n            database.setDefaultSchemaName(connectInfo.getSchemaName());\n        }\n        if (StringUtils.isNotBlank(connectInfo.getDatabaseName())) {\n            database.setDefaultCatalogName(connectInfo.getDatabaseName());\n        }\n        return database;\n    }\n\n    private DiffResult generateDiff(Database sourceDatabase, Database targetDatabase) throws LiquibaseException {","sourceCodeStart":94,"sourceCodeEnd":130,"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/DbDiffServiceImpl.java#L94-L130","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the dataSourceId exists in the workspace datasource table before invoking diff.","Refresh the datasource picker in the UI and reselect both source and target.","Check that the datasource belongs to the current workspace context."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"WorkspaceDataSource ds = workspaceDataSourceService.queryDisplayDataSourceById(dataSourceId, true);\nif (ds == null) {\n    // do not call diff; prompt user to reselect datasource\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate both source and target dataSourceIds exist before invoking diff.","Refresh the datasource picker if a datasource was recently deleted."],"tags":["diff","datasource","not-found"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}