{"record":{"id":"d1efaed8b71fc2c7","repo":"OtterMind/Chat2DB","slug":"database-delete-notsupportdatabase","errorCode":"database.delete.notSupportDatabase","errorMessage":"database.delete.notSupportDatabase","messagePattern":"database\\.delete\\.notSupportDatabase","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/DbDatabaseObjectDeleteServiceImpl.java","lineNumber":180,"sourceCode":"    private void reconnectForDatabaseDelete(String dbType) {\n        if (!DatabaseTypeEnum.POSTGRESQL.name().equalsIgnoreCase(dbType)) {\n            return;\n        }\n        connectionContextService.rebindCurrentDatabase(maintenanceDatabase());\n    }\n\n    private String requireName(String name, String fieldName) {\n        String trimmed = StringUtils.trimToNull(name);\n        if (trimmed == null) {\n            throw new BusinessException(\"database.delete.\" + fieldName + \"Required\");\n        }\n        return trimmed;\n    }\n\n    private void assertDatabaseDeletionSupported(String dbType) {\n        DBConfig dbConfig = Chat2DBContext.getDBConfig(dbType);\n        if (dbConfig == null || !dbConfig.isSupportDatabase()) {\n            throw new BusinessException(\"database.delete.notSupportDatabase\");\n        }\n    }\n\n    private void rejectSystemDatabase(String dbType, String databaseName) {\n        if (DatabaseTypeEnum.MYSQL.name().equalsIgnoreCase(dbType)\n                && MYSQL_SYSTEM_DATABASES.contains(StringUtils.lowerCase(databaseName))) {\n            throw new BusinessException(\"database.delete.systemDatabaseForbidden\");\n        }\n        if (DatabaseTypeEnum.POSTGRESQL.name().equalsIgnoreCase(dbType)\n                && POSTGRESQL_SYSTEM_DATABASES.contains(StringUtils.lowerCase(databaseName))) {\n            throw new BusinessException(\"database.delete.systemDatabaseForbidden\");\n        }\n    }\n\n    private Connection requireConnection() {\n        Connection connection = Chat2DBContext.getConnection();\n        if (connection == null) {\n            throw new BusinessException(\"database.delete.connectionFailed\");","sourceCodeStart":162,"sourceCodeEnd":198,"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/DbDatabaseObjectDeleteServiceImpl.java#L162-L198","documentation":"Thrown by assertDatabaseDeletionSupported when the resolved DBConfig is null or its isSupportDatabase() flag is false for the current connection's dbType. This guards prepareDatabaseDelete and executeDatabaseDelete so that database-level DROP operations are only attempted on DB types that actually expose a database concept. It is a capability check on the dialect plugin configuration, not a runtime permission check.","triggerScenarios":"Calling prepareDatabaseDelete() or executeDatabaseDelete() on a connection whose dbType (e.g. REDIS, MONGODB, or a flat-namespace dialect) has DBConfig.isSupportDatabase()==false, or whose dbType has no registered DBConfig (Chat2DBContext.getDBConfig returns null). Only MYSQL and POSTGRESQL connections pass this gate in the current SUPPORTED_TYPES set.","commonSituations":"Selecting a Redis/MongoDB/Oracle connection in the UI and invoking the delete-database action; pointing the datasource at a dbType string that does not match any registered plugin DBConfig key; a plugin misconfiguration where isSupportDatabase was left at its default false.","solutions":["Switch the active datasource to a MySQL or PostgreSQL connection before invoking database delete.","Verify the dbType stored on the ConnectionProfile resolves to a DBConfig whose isSupportDatabase() is true (check the dialect's DBConfig registration).","If the dialect genuinely supports databases, correct the plugin's DBConfig so isSupportDatabase() returns true."],"exampleFix":"// before\nConnectionProfile profile = connectionContextService.currentProfile();\ndlTemplateService.prepareDatabaseDelete(req); // dbType=REDIS -> notSupportDatabase\n\n// after\n// ensure profile.getDbType() is MYSQL or POSTGRESQL before calling\nif (Set.of(\"MYSQL\",\"POSTGRESQL\").contains(StringUtils.upperCase(profile.getDbType()))) {\n    dlTemplateService.prepareDatabaseDelete(req);\n}","handlingStrategy":"validation","validationCode":"// Pre-check database-deletion capability before calling prepare/execute\nDBConfig cfg = Chat2DBContext.getDBConfig(dbType);\nif (cfg == null || !cfg.isSupportDatabase()) {\n    // do not call prepareDatabaseDelete / executeDatabaseDelete\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict the delete-database UI action to connections whose dbType is MYSQL or POSTGRESQL.","Cache the DBConfig capability flags and check isSupportDatabase() client-side before dispatching."],"tags":["database-delete","dbtype-capability","validation"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}