{"record":{"id":"917983d29f8f4d56","repo":"provectus/kafka-ui","slug":"you-specified-username-but-did-not-specify-passwor","errorCode":null,"errorMessage":"You specified username but did not specify password","messagePattern":"You specified username but did not specify password","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"kafka-ui-api/src/main/java/com/provectus/kafka/ui/util/WebClientConfigurator.java","lineNumber":104,"sourceCode":"      );\n\n      KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());\n      keyManagerFactory.init(keyStore, keystorePassword.toCharArray());\n      contextBuilder.keyManager(keyManagerFactory);\n    }\n\n    // Create webclient\n    SslContext context = contextBuilder.build();\n\n    httpClient = httpClient.secure(t -> t.sslContext(context));\n    return this;\n  }\n\n  public WebClientConfigurator configureBasicAuth(@Nullable String username, @Nullable String password) {\n    if (username != null && password != null) {\n      builder.defaultHeaders(httpHeaders -> httpHeaders.setBasicAuth(username, password));\n    } else if (username != null) {\n      throw new ValidationException(\"You specified username but did not specify password\");\n    } else if (password != null) {\n      throw new ValidationException(\"You specified password but did not specify username\");\n    }\n    return this;\n  }\n\n  public WebClientConfigurator configureBufferSize(DataSize maxBuffSize) {\n    builder.codecs(c -> c.defaultCodecs().maxInMemorySize((int) maxBuffSize.toBytes()));\n    return this;\n  }\n\n  public WebClientConfigurator configureObjectMapper(ObjectMapper mapper) {\n    builder.codecs(codecs -> {\n      codecs.defaultCodecs()\n          .jackson2JsonEncoder(new Jackson2JsonEncoder(mapper, MediaType.APPLICATION_JSON));\n      codecs.defaultCodecs()\n          .jackson2JsonDecoder(new Jackson2JsonDecoder(mapper, MediaType.APPLICATION_JSON));\n    });","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/util/WebClientConfigurator.java#L86-L122","documentation":"WebClientConfigurator.configureBasicAuth() builds HTTP basic-auth for outgoing WebClients (e.g. Kafka Connect or schema registry clients). Basic auth needs both a username and password; if only a username is supplied it throws this ValidationException rather than sending incomplete credentials.","triggerScenarios":"Cluster properties define `connect`/`schemaRegistry` basicAuthUsername (or username) without the matching basicAuthPassword, when a client for that service is built.","commonSituations":"Secret templating where the password key failed to render (empty value trimmed to null); copying an example config and omitting the password; password supplied via env var that wasn't set in the deployment.","solutions":["Provide the matching password property alongside the username in the cluster config","Check secret/env templating: the password env var or mounted key must exist and be non-empty at startup","Restart kafka-ui after adding the missing value"],"exampleFix":"// before\nkafka:\n  clusters:\n    - name: local\n      schemaRegistry:\n        basicAuthUsername: admin\n// after\nkafka:\n  clusters:\n    - name: local\n      schemaRegistry:\n        basicAuthUsername: admin\n        basicAuthPassword: ${SR_PASSWORD}","handlingStrategy":"validation","validationCode":"if (username != null && password == null) {\n  throw new IllegalArgumentException(\"basicAuthUsername set but basicAuthPassword missing\");\n}","typeGuard":"boolean hasCompleteBasicAuth(String u, String p) { return u != null && p != null; }","tryCatchPattern":"try {\n  webClient = configurator.configureBasicAuth(user, pass).build();\n} catch (ValidationException e) {\n  log.error(\"Incomplete basic auth config: {}\", e.getMessage());\n}","preventionTips":["Always set username and password pairs together in one template block","Fail fast in CI if a referenced secret key is empty","Validate cluster properties on startup with a config test"],"tags":["configuration","basic-auth","webclient"],"backgroundTag":"missing-credentials","analyzedSha":"83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7","analyzedAt":"2026-09-08T04:35:39.002Z","contentChangedAt":"2026-09-08T04:35:39.002Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}