redis/jedis · error · IllegalArgumentException

DIALECT=0 cannot be set.

Error message

DIALECT=0 cannot be set.

What it means

DefaultJedisClientConfig.Builder.searchDialect(int) throws IllegalArgumentException when the dialect is set to 0. DIALECT=0 means 'use server default' and is not a settable value; the builder requires an explicit dialect of 1 or higher.

Solutions

  1. Set an explicit dialect, e.g. .searchDialect(2) (or 1) in the client config
  2. If 'server default' is desired, omit the searchDialect call entirely so the field stays unset
  3. Fix config parsing so an absent/0 dialect maps to 'unset' rather than calling the setter with 0

Example fix

// before
DefaultJedisClientConfig cfg = DefaultJedisClientConfig.builder()
    .searchDialect(dialectFromProps) // 0 -> IllegalArgumentException
    .build();
// after
DefaultJedisClientConfig.Builder b = DefaultJedisClientConfig.builder();
if (dialectFromProps > 0) b.searchDialect(dialectFromProps);
DefaultJedisClientConfig cfg = b.build();
Defensive patterns

Strategy: validation

Validate before calling

if (searchDialect == 0) {
  throw new IllegalArgumentException("searchDialect must be >= 1; omit the setter to use server default");
}
builder.searchDialect(searchDialect);

Try / catch

try {
  builder.searchDialect(dialect);
} catch (IllegalArgumentException e) {
  // dialect was 0; fall back to server default (skip setter)
}

Prevention

When it happens

Trigger: Calling .searchDialect(0) on DefaultJedisClientConfig.Builder; building a config where the dialect variable defaults to 0 (e.g. an unset int parsed from properties) and is passed through unchanged.

Common situations: Reading a DIALECT setting from application.properties/environment where 0 was chosen as a 'no preference' sentinel; porting code that used the old behavior of leaving dialect null; SQL-style search query tuning experiments with dialect 0.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/de8324ce35acf4f3. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/DefaultJedisClientConfig.java:501

     */
    public Builder jsonObjectMapper(JsonObjectMapper jsonObjectMapper) {
      this.jsonObjectMapper = jsonObjectMapper;
      return this;
    }

    /**
     * Sets the default search dialect for RediSearch commands. Defaults to
     * {@link SearchProtocol#DEFAULT_DIALECT}.
     * <p>
     * <b>Not honored by the legacy {@link Jedis} class</b> — only the {@link UnifiedJedis} family
     * reads this value when constructing its command pipeline.
     * @param searchDialect the dialect version (must not be 0)
     * @return this
     * @throws IllegalArgumentException if {@code searchDialect == 0}
     */
    public Builder searchDialect(int searchDialect) {
      if (searchDialect == 0) {
        throw new IllegalArgumentException("DIALECT=0 cannot be set.");
      }
      this.searchDialect = searchDialect;
      return this;
    }

    public Builder from(JedisClientConfig instance) {
      this.redisProtocol = instance.getRedisProtocol();
      this.autoNegotiateProtocol = instance.isAutoNegotiateProtocol();
      this.connectionTimeoutMillis = instance.getConnectionTimeoutMillis();
      this.socketTimeoutMillis = instance.getSocketTimeoutMillis();
      this.blockingSocketTimeoutMillis = instance.getBlockingSocketTimeoutMillis();
      this.credentialsProvider = instance.getCredentialsProvider();
      this.database = instance.getDatabase();
      this.clientName = instance.getClientName();
      this.ssl = instance.isSsl();
      this.sslSocketFactory = instance.getSslSocketFactory();
      this.sslParameters = instance.getSslParameters();
      this.sslOptions = instance.getSslOptions();

View on GitHub (pinned to 6dac31d4c2)