{"record":{"id":"710f0d8d6e050c84","repo":"alibaba/spring-ai-alibaba","slug":"host-cannot-be-null-or-blank","errorCode":null,"errorMessage":"host cannot be null or blank","messagePattern":"host 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":210,"sourceCode":"            default -> throw new IllegalArgumentException(\n                    \"Unsupported dbType: \" + dbType + \". Supported values: mysql, postgresql, oracle, h2\");\n        };\n    }\n\n    /**\n     * 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;","sourceCodeStart":192,"sourceCodeEnd":228,"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#L192-L228","documentation":"Configuration validation failure in DatabaseStore.validateConnectionInfo, a private precondition helper called from buildJdbcUrl. The JDBC URL cannot be constructed without a host, so when the configured host is null or blank IllegalArgumentException is thrown at store initialization, before any connection is attempted. This indicates a misconfigured DatabaseStore (missing host in its connection settings) rather than a runtime connectivity problem; fix the configuration.","triggerScenarios":"Calling buildJdbcUrl with host == null or host.isBlank(), typically because the host config key was not provided or was trimmed to an empty string.","commonSituations":"Deployment config lacks the DB host entry; using a container where the DB_HOST env var is unset; copy-pasted config where hostname was accidentally deleted.","solutions":["Provide the database host (e.g. localhost or the DB service hostname) in the store configuration","Verify the environment variable/config key that supplies the host is populated","Add a startup check that all connection fields are non-blank before creating the store"],"exampleFix":"// before\n.host(env.getProperty(\"db.host\")) // may be null\n// after\nString host = env.getRequiredProperty(\"db.host\");\n.host(host)","handlingStrategy":"validation","validationCode":"if (host == null || host.isBlank()) throw new IllegalArgumentException(\"db host must be configured\");","typeGuard":"boolean hasHost(java.util.Map<String,String> cfg) { String h = cfg.get(\"db.host\"); return h != null && !h.isBlank(); }","tryCatchPattern":"try { store = DatabaseStore.builder().host(host).build(); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"host\")) { log.error(\"DB host missing; set db.host\"); } throw e; }","preventionTips":["Use Spring's env.getRequiredProperty(\"db.host\") to fail fast","Template configs with non-empty example hosts and startup validation","Check container env vars are injected before app start"],"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"}