{"record":{"id":"6151980c228f745c","repo":"redis/jedis","slug":"master-name-is-required-for-sentinel-mode","errorCode":null,"errorMessage":"Master name is required for Sentinel mode","messagePattern":"Master name is required for Sentinel mode","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/builders/SentinelClientBuilder.java","lineNumber":100,"sourceCode":"  }\n\n  @Override\n  protected SentinelClientBuilder<C> self() {\n    return this;\n  }\n\n  @Override\n  protected ConnectionProvider createDefaultConnectionProvider() {\n    return new SentineledConnectionProvider(this.masterName, this.clientConfig, this.cache,\n        this.poolConfig, this.sentinels, this.sentinelClientConfig, sentinelReconnectDelay);\n  }\n\n  @Override\n  protected void validateSpecificConfiguration() {\n    validateCommonConfiguration();\n\n    if (masterName == null || masterName.trim().isEmpty()) {\n      throw new IllegalArgumentException(\"Master name is required for Sentinel mode\");\n    }\n\n    if (sentinels == null || sentinels.isEmpty()) {\n      throw new IllegalArgumentException(\n          \"At least one sentinel must be specified for Sentinel mode\");\n    }\n  }\n\n  @Override\n  public C build() {\n    if (sentinelClientConfig == null) {\n      // Sentinel connections use the legacy Jedis client which does not support RESP3\n      // auto-negotiation, so the default config must opt out to avoid a spurious warning.\n      sentinelClientConfig = DefaultJedisClientConfig.builder().serverDefaultProtocol().build();\n    }\n\n    return super.build();\n  }","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/builders/SentinelClientBuilder.java#L82-L118","documentation":"Sentinel mode requires the logical name of the master monitored by the Sentinel quorum; the client uses it to ask sentinels for the current master address. SentinelClientBuilder.validateSpecificConfiguration() throws this IllegalArgumentException when masterName is null or blank (null/whitespace-only) at build() time.","triggerScenarios":"Building a RedisSentinelClient without calling .masterName(...), or with .masterName(\" \") / .masterName(\"\") / a null value sourced from configuration.","commonSituations":"Missing or misnamed key in properties/env (e.g. redis.master vs redis.masterName) resolving to null; YAML indentation issues yielding empty string; copying a standalone example into a Sentinel deployment without adding the master name.","solutions":["Call .masterName(\"mymaster\") with the exact master name configured on your sentinels (verify with SENTINEL masters).","Fail fast at config load if the master-name property is missing/blank instead of passing it to the builder.","Trim the value and check !name.isBlank() (or equivalent for JDK 8) before building."],"exampleFix":"// before\nRedisSentinelClient client = RedisSentinelClient.builder()\n    .sentinels(sentinels)\n    .build(); // throws: no masterName\n// after\nRedisSentinelClient client = RedisSentinelClient.builder()\n    .masterName(\"mymaster\")\n    .sentinels(sentinels)\n    .build();","handlingStrategy":"validation","validationCode":"if (masterName == null || masterName.trim().isEmpty()) {\n  throw new IllegalArgumentException(\"sentinel masterName is required\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the master name in a named config property and fail fast when absent.","Cross-check the name against `SENTINEL masters` output on the actual deployment.","Trim whitespace from operator-supplied values before building."],"tags":["jedis","sentinel","builder","configuration","missing-argument"],"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"}