{"record":{"id":"5ef3894fab850606","repo":"OtterMind/Chat2DB","slug":"database-delete-confirmnamemismatch","errorCode":"database.delete.confirmNameMismatch","errorMessage":"database.delete.confirmNameMismatch","messagePattern":"database\\.delete\\.confirmNameMismatch","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":268,"sourceCode":"        List<Schema> schemas = Chat2DBContext.getDbMetaData().schemas(connection, databaseName);\n        boolean exists = schemas != null && schemas.stream()\n                .anyMatch(schema -> StringUtils.equals(schema.getName(), schemaName));\n        if (!exists) {\n            throw new BusinessException(\"database.delete.schemaNotExists\");\n        }\n    }\n\n    private String schemaConfirmName(String schemaName) {\n        return schemaName;\n    }\n\n    private String buildDropSchema(String dbType, String schemaName) {\n        return Chat2DBContext.getDbMetaData(dbType).getSqlBuilder().ddl().schema().buildDropSchema(schemaName);\n    }\n\n    private void assertConfirmName(String actualConfirmName, String expectedConfirmName) {\n        if (!StringUtils.equals(actualConfirmName, expectedConfirmName)) {\n            throw new BusinessException(\"database.delete.confirmNameMismatch\");\n        }\n    }\n\n    private String maintenanceDatabase() {\n        return \"postgres\";\n    }\n}\n","sourceCodeStart":250,"sourceCodeEnd":276,"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#L250-L276","documentation":"Thrown by assertConfirmName when the user-supplied confirmName does not exactly equal the expected confirm name (which is the database or schema name itself). This is the typed-confirmation safety gate for destructive DROP operations — the user must type the exact object name to proceed. Fires in executeDatabaseDelete and executeSchemaDelete, not in prepare.","triggerScenarios":"Calling executeDatabaseDelete or executeSchemaDelete where param.getConfirmName() does not StringUtils.equals the actual database/schema name. Even a trailing space or different case fails the check (exact equals, case-sensitive).","commonSituations":"User mistypes the confirmation name; UI sends an empty or stale confirmName; copy-paste introduces whitespace; case mismatch between displayed name and typed input.","solutions":["Pass the exact database or schema name as confirmName with no extra whitespace.","Trim the confirmName in the UI before submitting, but note the check is case-sensitive.","Re-run prepare to obtain the confirmName and echo it back exactly in execute."],"exampleFix":"// before\nexecuteDatabaseDelete(DbDatabaseObjectDeleteExecuteRequest.builder()\n    .databaseName(\"mydb\")\n    .confirmName(\"MyDB\")  // case mismatch\n    .build());\n\n// after\nexecuteDatabaseDelete(DbDatabaseObjectDeleteExecuteRequest.builder()\n    .databaseName(\"mydb\")\n    .confirmName(\"mydb\")  // exact match\n    .build());","handlingStrategy":"validation","validationCode":"// Before calling execute, ensure confirmName exactly equals the object name\nif (!StringUtils.equals(param.getConfirmName(), expectedName)) {\n    // block submission; show the exact required name to the user\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Display the exact required confirmation name and validate client-side before submit.","Use the confirmName returned by prepare() as the value for execute()."],"tags":["database-delete","schema-delete","confirmation","safety-guard"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}