{"record":{"id":"90cb897ba6504be5","repo":"apache/seatunnel","slug":"database-name-is-null-or-empty","errorCode":null,"errorMessage":"Database name is null or empty.","messagePattern":"Database name is null or empty\\.","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/catalog/HudiCatalog.java","lineNumber":126,"sourceCode":"        } catch (Exception e) {\n            log.info(\"Hudi catalog close error.\", e);\n        }\n    }\n\n    @Override\n    public String name() {\n        return catalogName;\n    }\n\n    @Override\n    public String getDefaultDatabase() throws CatalogException {\n        return \"default\";\n    }\n\n    @Override\n    public boolean databaseExists(String databaseName) throws CatalogException {\n        if (StringUtils.isEmpty(databaseName)) {\n            throw new CatalogException(\"Database name is null or empty.\");\n        }\n        return listDatabases().contains(databaseName);\n    }\n\n    @Override\n    public List<String> listDatabases() throws CatalogException {\n        try {\n            FileStatus[] fileStatuses = fs.listStatus(tableParentDfsPath);\n            return Arrays.stream(fileStatuses)\n                    .filter(FileStatus::isDirectory)\n                    .map(fileStatus -> fileStatus.getPath().getName())\n                    .collect(Collectors.toList());\n        } catch (IOException e) {\n            throw new CatalogException(\"Listing database exception.\", e);\n        }\n    }\n\n    @Override","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/catalog/HudiCatalog.java#L108-L144","documentation":"HudiCatalog.databaseExists treats a null or empty database name as a programming/config error rather than a false result, throwing CatalogException. The catalog identifies databases as subdirectories under the table parent path, so a valid non-empty name is required to check existence.","triggerScenarios":"Calling databaseExists(null) or databaseExists(\"\") directly, or indirectly via listTables/createDatabase/dropDatabase with an empty database portion of the TablePath, or via open() with a blank default database.","commonSituations":"TablePath built without a database component (only table name); config option for database left empty; user code passing empty string assuming defaults are applied.","solutions":["Always specify an explicit database name in the table path, e.g. schema.table instead of just table.","Set the catalog's default database if you intend to rely on it, ensuring it is non-empty.","Fix caller code that constructs TablePath to fill in the database field.","Validate the database name is non-blank before invoking catalog APIs."],"exampleFix":"// before\nTablePath.of(\"\", \"my_table\")\n// after\nTablePath.of(\"my_db\", \"my_table\")","handlingStrategy":"validation","validationCode":"if (databaseName == null || databaseName.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"database name must be a non-empty string\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    boolean exists = catalog.databaseExists(db);\n} catch (CatalogException e) {\n    throw new IllegalArgumentException(\"Provide a non-empty database name: \" + e.getMessage(), e);\n}","preventionTips":["Always build TablePath with both database and table (schema.table).","Check for empty database fields when parsing user-supplied table identifiers.","Rely on the catalog default database only after confirming it is configured."],"tags":["validation","catalog","hudi","null-argument"],"backgroundTag":"empty-required-field","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"}