{"record":{"id":"17ed1171f9cf20c4","repo":"alibaba/spring-ai-alibaba","slug":"database-cannot-be-null-or-blank","errorCode":null,"errorMessage":"database cannot be null or blank","messagePattern":"database cannot be null or blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/DatabaseStore.java","lineNumber":216,"sourceCode":"     * Validate connection parameters for JDBC URL construction.\n     *\n     * @param dbType   database type\n     * @param host     database host\n     * @param port     database port\n     * @param database database name\n     */\n    private static void validateConnectionInfo(String dbType, String host, int port, String database) {\n        if (dbType == null || dbType.isBlank()) {\n            throw new IllegalArgumentException(\"dbType cannot be null or blank\");\n        }\n        if (host == null || host.isBlank()) {\n            throw new IllegalArgumentException(\"host cannot be null or blank\");\n        }\n        if (port <= 0) {\n            throw new IllegalArgumentException(\"port must be greater than 0\");\n        }\n        if (database == null || database.isBlank()) {\n            throw new IllegalArgumentException(\"database cannot be null or blank\");\n        }\n    }\n\n    /**\n     * Resolve table name with backward-compatible default behavior.\n     *\n     * @param tableName candidate table name\n     * @return resolved table name\n     */\n    private static String resolveTableName(String tableName) {\n        if (tableName == null || tableName.isBlank()) {\n            return DEFAULT_TABLE_NAME;\n        }\n        return tableName;\n    }\n\n    /**\n     * Minimal JDBC DataSource implementation based on DriverManager.","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/DatabaseStore.java#L198-L234","documentation":"Configuration validation failure in DatabaseStore.validateConnectionInfo, a private precondition helper called from buildJdbcUrl. The database name is a required segment of the JDBC URL; when it is null or blank IllegalArgumentException is thrown while constructing the URL at store initialization. This signals missing database configuration rather than a connectivity issue; set the database name in the DatabaseStore connection settings.","triggerScenarios":"Calling buildJdbcUrl with database == null or blank, e.g. the database name key absent from config or the caller passing an empty string after sanitization.","commonSituations":"New environment provisioned without creating/setting the database name; config template placeholder never filled in; empty value produced by a CI variable substitution.","solutions":["Set the target database/schema name in the store configuration","Confirm the database actually exists on the server with that name","Validate that the config key supplying the database name is non-blank before initialization"],"exampleFix":"// before\n.database(cfg.getOrDefault(\"db.name\", \"\"))\n// after\nString dbName = cfg.getProperty(\"db.name\");\nif (dbName == null || dbName.isBlank()) throw new IllegalStateException(\"db.name must be set\");\n.database(dbName)","handlingStrategy":"validation","validationCode":"if (database == null || database.isBlank()) throw new IllegalArgumentException(\"database name must be configured\");","typeGuard":"boolean hasDatabase(java.util.Map<String,String> cfg) { String d = cfg.get(\"db.name\"); return d != null && !d.isBlank(); }","tryCatchPattern":"try { store = DatabaseStore.builder().database(db).build(); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"database\")) { log.error(\"Database name missing\"); } throw e; }","preventionTips":["Create the database in provisioning scripts and export its name","Validate all four connection fields together before constructing the store","Avoid getOrDefault(key, \"\") patterns that hide missing values"],"tags":["database","configuration","validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}