{"record":{"id":"b21340b11b5caef5","repo":"testcontainers/testcontainers-java","slug":"kibana-credentials-cannot-be-blank","errorCode":null,"errorMessage":"Kibana credentials cannot be blank","messagePattern":"Kibana credentials cannot be blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/elasticsearch/src/main/java/org/testcontainers/elasticsearch/KibanaContainer.java","lineNumber":206,"sourceCode":"\n    /**\n     * Configures credentials Kibana will use for authentication.\n     *\n     * @param username the Elasticsearch username (cannot be 'elastic')\n     * @param password the password\n     * @return this container instance\n     * @throws IllegalStateException if a service account token is already configured\n     * @throws IllegalArgumentException if credentials are invalid\n     */\n    public KibanaContainer withKibanaUsernameAndPassword(String username, String password) {\n        if (elasticsearchServiceAccountToken != null) {\n            throw new IllegalStateException(\n                \"Conflicting Elasticsearch credentials: provide either a service account token \" +\n                \"or a username/password pair, not both.\"\n            );\n        }\n        if (StringUtils.isAnyBlank(username, password)) {\n            throw new IllegalArgumentException(\"Kibana credentials cannot be blank\");\n        }\n        if (!username.equals(username.trim()) || !password.equals(password.trim())) {\n            throw new IllegalArgumentException(\"Kibana credentials cannot have leading or trailing whitespace\");\n        }\n        if (\"elastic\".equals(username)) {\n            throw new IllegalArgumentException(\"Username 'elastic' is reserved for internal use by Elasticsearch\");\n        }\n\n        this.elasticsearchUsername = username;\n        this.elasticsearchPassword = password;\n        return this;\n    }\n\n    /**\n     * Configures a service account token for Elasticsearch authentication.\n     *\n     * @param token the service account token\n     * @return this container instance","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/elasticsearch/src/main/java/org/testcontainers/elasticsearch/KibanaContainer.java#L188-L224","documentation":"withKibanaUsernameAndPassword validates that both username and password are non-blank (Apache StringUtils.isAnyBlank). Blank credentials would produce a Kibana container that cannot authenticate to Elasticsearch, so the library rejects them eagerly with IllegalArgumentException.","triggerScenarios":"Calling withKibanaUsernameAndPassword(null, ...) / (\"\", ...) / (\" \", ...) — any null, empty, or whitespace-only username or password.","commonSituations":"Reading credentials from an unset environment variable or empty test property; placeholder strings accidentally left as spaces; password not yet provisioned by an earlier setup step.","solutions":["Pass a real non-blank username and non-blank password.","Validate/configure credential sources before building the container.","Use the managed mode default (Elasticsearch password from the ES container) instead of explicit credentials when appropriate."],"exampleFix":"// before\nString user = System.getenv(\"KIBANA_USER\"); // may be null/blank\nkibana.withKibanaUsernameAndPassword(user, pass);\n// after\nif (user == null || user.isBlank()) { user = \"kibana_user\"; }\nkibana.withKibanaUsernameAndPassword(user, pass);","handlingStrategy":"validation","validationCode":"if (username == null || username.isBlank() || password == null || password.isBlank()) throw new IllegalArgumentException(\"Kibana credentials required\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate credentials loaded from env/properties before building the container.","Provide defaults in test fixtures instead of relying on possibly-unset env vars.","Fail fast at config load time, not container setup time."],"tags":["kibana","elasticsearch","validation","credentials"],"backgroundTag":"empty-required-field","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}