{"record":{"id":"01dea9db5ba17df8","repo":"redis/jedis","slug":"either-uri-or-host-port-must-be-specified","errorCode":null,"errorMessage":"Either URI or host/port must be specified","messagePattern":"Either URI or host/port must be specified","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/builders/StandaloneClientBuilder.java","lineNumber":85,"sourceCode":"  }\n\n  @Override\n  protected StandaloneClientBuilder<C> self() {\n    return this;\n  }\n\n  @Override\n  protected ConnectionProvider createDefaultConnectionProvider() {\n    return new PooledConnectionProvider(this.hostAndPort, this.clientConfig, this.cache,\n        this.poolConfig, this.maintNotificationsConfig);\n  }\n\n  @Override\n  protected void validateSpecificConfiguration() {\n    validateCommonConfiguration();\n\n    if (hostAndPort == null) {\n      throw new IllegalArgumentException(\"Either URI or host/port must be specified\");\n    }\n  }\n\n  /**\n   * Sets the Redis server URI from a string.\n   * <p>\n   * This method extracts connection parameters from the URI and merges them into the current client\n   * configuration. If a client configuration was previously set via\n   * {@link #clientConfig(JedisClientConfig)}, only the values explicitly provided in the URI will\n   * override the existing configuration. Values not present in the URI will be preserved from the\n   * existing configuration.\n   * <p>\n   * <b>This method sets:</b>\n   * <ul>\n   * <li>Host and port from the URI (always set)</li>\n   * <li>Client configuration with URI-derived values (merged with existing config if present)</li>\n   * </ul>\n   * <p>","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/builders/StandaloneClientBuilder.java#L67-L103","documentation":"StandaloneClientBuilder needs a target Redis endpoint: either a HostAndPort or a URI. validateSpecificConfiguration() throws this IllegalArgumentException when hostAndPort is still null at build() time, meaning neither a host/port/endpoint nor a URI was supplied (the builder stores URI-derived values into hostAndPort).","triggerScenarios":"Building a RedisClient without calling .hostAndPort(...), .endpoint(...), or .uri(...) / .uri(String), so no address was recorded before build().","commonSituations":"Constructing the builder conditionally and skipping all address setters when a config branch doesn't match; passing a malformed URI string to .uri(String) expecting it to be parsed later; copy-pasted builder code where the .hostAndPort line was deleted.","solutions":["Add .hostAndPort(\"localhost\", 6379) (or .endpoint(...) / .uri(\"redis://localhost:6379\")) before build().","If using .uri(String), verify the string parses correctly and the call precedes build().","Ensure exactly one address-setting path in conditional code always sets an endpoint; validate at startup."],"exampleFix":"// before\nRedisClient client = RedisClient.builder()\n    .clientConfig(ClientConfig.builder().resp3().build())\n    .build(); // throws: no endpoint\n// after\nRedisClient client = RedisClient.builder()\n    .hostAndPort(\"localhost\", 6379)\n    .clientConfig(ClientConfig.builder().resp3().build())\n    .build();","handlingStrategy":"validation","validationCode":"if (hostAndPort == null && uri == null) {\n  throw new IllegalArgumentException(\"set hostAndPort or uri for the Redis endpoint\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  client = RedisClient.builder().hostAndPort(host, port).build();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Either URI or host/port\")) {\n    throw new ConfigurationException(\"redis endpoint missing\", e);\n  }\n  throw e;\n}","preventionTips":["Make the endpoint the first builder call, before optional config.","Validate at startup that exactly one of URI/host-port is set in configuration.","Route all endpoint settings through a single helper that guarantees a value."],"tags":["jedis","standalone","builder","configuration","missing-endpoint"],"backgroundTag":"missing-required-config-field","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}