{"record":{"id":"fe70e9850c057813","repo":"apache/seatunnel","slug":"database-tablepath-getdatabasename-does-not-e","errorCode":null,"errorMessage":"Database ${tablePath.getDatabaseName()} does not exist in catalog ${name()}","messagePattern":"Database (.+?) does not exist in catalog (.+?)","errorType":"exception","errorClass":"DatabaseNotExistException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java","lineNumber":129,"sourceCode":"    public boolean tableExists(TablePath tablePath) throws CatalogException {\n        try {\n            return listTables(tablePath.getDatabaseName()).contains(tablePath.getTableName());\n        } catch (DatabaseNotExistException e) {\n            return false;\n        }\n    }\n\n    @Override\n    public CatalogTable getTable(TablePath tablePath)\n            throws CatalogException, TableNotExistException {\n        throw CommonError.unsupportedOperation(name(), \"get table with tablePath \");\n    }\n\n    @Override\n    public void createTable(TablePath tablePath, CatalogTable table, boolean ignoreIfExists)\n            throws TableAlreadyExistException, DatabaseNotExistException, CatalogException {\n        if (!databaseExists(tablePath.getDatabaseName())) {\n            throw new DatabaseNotExistException(name(), tablePath.getDatabaseName());\n        }\n        if (tableExists(tablePath)) {\n            if (ignoreIfExists) return;\n            throw new TableAlreadyExistException(name(), tablePath);\n        }\n        try {\n            MongoDatabase db = mongoClient.getDatabase(tablePath.getDatabaseName());\n            db.createCollection(tablePath.getTableName());\n        } catch (Exception e) {\n            throw new CatalogException(\n                    \"Failed to create collection: \" + tablePath.getFullName(), e);\n        }\n    }\n\n    @Override\n    public void dropTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {\n        if (!tableExists(tablePath)) {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java#L111-L147","documentation":"createTable(tablePath, table, ignoreIfExists) requires the parent database to exist; if databaseExists(tablePath.getDatabaseName()) is false it throws DatabaseNotExistException. MongoDB does not auto-create databases through this catalog path — you must createDatabase first.","triggerScenarios":"Calling createTable for a database that was never created via catalog.createDatabase(), a misspelled database name in the target TablePath, or hidden databases due to insufficient privileges making databaseExists return false.","commonSituations":"Submitting a SeaTunnel job whose sink table path points to a new database without creating it first; renaming a database in config without creating it; auth-restricted user cannot see the database.","solutions":["Call catalog.createDatabase(TablePath.of(db, \"_\"), true) (or equivalent) before createTable.","Verify the database name spelling/casing in the table path.","Ensure the user can list databases; otherwise createDatabase/databaseExists checks fail.","If the tooling supports it, use ignoreIfExists / create-and-ignore semantics on the parent database."],"exampleFix":"// before\ncatalog.createTable(TablePath.of(\"newdb\", \"coll\"), table, true);\n// after\ncatalog.createDatabase(TablePath.of(\"newdb\", \"_\"), true);\ncatalog.createTable(TablePath.of(\"newdb\", \"coll\"), table, true);","handlingStrategy":"validation","validationCode":"if (!catalog.listDatabases().contains(tablePath.getDatabaseName())) {\n    catalog.createDatabase(TablePath.of(tablePath.getDatabaseName(), \"_\"), true);\n}","typeGuard":null,"tryCatchPattern":"try {\n    catalog.createTable(tablePath, table, ignoreIfExists);\n} catch (DatabaseNotExistException e) {\n    catalog.createDatabase(TablePath.of(tablePath.getDatabaseName(), \"_\"), true);\n    catalog.createTable(tablePath, table, ignoreIfExists);\n}","preventionTips":["Always createDatabase before createTable for new databases","Validate TablePath names against listDatabases output","Ensure the catalog user can list databases"],"tags":["mongodb","catalog","database-not-exist"],"backgroundTag":"entity-not-found","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}