redis/jedis · error · IllegalArgumentException

DIALECT=0 cannot be set.

Error message

DIALECT=0 cannot be set.

What it means

The Redis Search DIALECT parameter must be >= 1; DIALECT=0 is not a valid value on the server. AbstractClientBuilder.searchDialect(int) validates this eagerly and throws IllegalArgumentException when 0 is passed.

Solutions

  1. Pass a valid dialect (1, 2, or higher per your RediSearch version).
  2. Omit the searchDialect() call to use the server default.
  3. Guard the builder call: only invoke it when a positive dialect is configured.

Example fix

// before
builder.searchDialect(config.getSearchDialect()); // 0 default
// after
if (config.getSearchDialect() > 0) {
  builder.searchDialect(config.getSearchDialect());
}
Defensive patterns

Strategy: validation

Validate before calling

if (dialect <= 0) throw new IllegalArgumentException("searchDialect must be >= 1");

Try / catch

try {
  builder.searchDialect(dialect);
} catch (IllegalArgumentException e) {
  log.error("Invalid search dialect: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling .searchDialect(0) on a RedisClient/RedisClusterClient builder, typically because a default/unset value (0) from a config field is passed through.

Common situations: Integer config field defaulting to 0 and passed unconditionally to the builder; misunderstanding that 0 means 'use server default' — instead omit the setter entirely.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at src/main/java/redis/clients/jedis/builders/AbstractClientBuilder.java:336

  /**
   * Sets the default search dialect for RediSearch operations.
   * <p>
   * The search dialect determines the query syntax and features available for RediSearch commands.
   * Different dialects support different query features and syntax variations.
   * <p>
   * Default is {@value redis.clients.jedis.search.SearchProtocol#DEFAULT_DIALECT}.
   * @param searchDialect the search dialect version
   * @return this builder
   * @throws IllegalArgumentException if dialect is 0 (not allowed)
   * @deprecated use {@link DefaultJedisClientConfig.Builder#searchDialect(int)} on the
   *             {@link JedisClientConfig} passed via {@link #clientConfig(JedisClientConfig)}. When
   *             this setter is used it is folded into the resulting client config at
   *             {@link #build()} time.
   */
  @Deprecated
  public T searchDialect(int searchDialect) {
    if (searchDialect == 0) {
      throw new IllegalArgumentException("DIALECT=0 cannot be set.");
    }
    this.searchDialect = searchDialect;
    return self();
  }

  /**
   * Validates common configuration parameters.
   * <p>
   * This method can be called by concrete builders to validate the common configuration before
   * building the client.
   * @throws IllegalArgumentException if any common configuration is invalid
   */
  protected void validateCommonConfiguration() {
    if (cache != null || cacheConfig != null) {
      if (clientConfig != null && !canNegotiateResp3(clientConfig)) {
        throw new IllegalArgumentException("Client-side caching is only supported with RESP3.");
      }
    }

View on GitHub (pinned to 6dac31d4c2)