redis/jedis · error · IllegalArgumentException
DIALECT=0 cannot be set.
Error message
DIALECT=0 cannot be set.
What it means
setDefaultSearchDialect(int) on CommandObjects rejects the value 0 because DIALECT=0 is not a settable default (dialect 0 means 'unspecified' server-side and would break dialect-optional command building). It throws IllegalArgumentException and does not change the default.
Solutions
- Pass a valid dialect (1, 2, or 3) to setDefaultSearchDialect
- Treat 0 as 'do not set' and skip calling setDefaultSearchDialect when the configured value is 0
- Coerce unset config to a sane default (e.g. 2) before calling
Example fix
// before
int dialect = Integer.parseInt(props.getProperty("search.dialect", "0"));
co.setDefaultSearchDialect(dialect); // 0 -> throw
// after
int dialect = Integer.parseInt(props.getProperty("search.dialect", "0"));
if (dialect != 0) co.setDefaultSearchDialect(dialect); Defensive patterns
Strategy: validation
Validate before calling
if (dialect < 1 || dialect > 3) throw new IllegalArgumentException("search dialect must be 1, 2 or 3"); Type guard
static boolean isValidDialect(int d) { return d == 1 || d == 2 || d == 3; } Try / catch
try { co.setDefaultSearchDialect(d); } catch (IllegalArgumentException e) { log.warn("ignoring invalid dialect " + d); } Prevention
- Treat 0 as 'unset' and skip the setter
- Validate config-sourced dialects at load time
- Default to dialect 2 when unset
When it happens
Trigger: Calling setDefaultSearchDialect(0), typically with a variable that defaulted to 0 (uninitialized int) or a config value of 0 meaning 'auto'.
Common situations: Reading dialect from properties/env where absence yields 0; users assuming 0 means 'use server default'; wiring an int field without a sentinel other than 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
- DIALECT=0 cannot be set.
- Range must not be null.
- binary ft.search is not implemented with resp3.
- TS.NRANGE/TS.NREVRANGE require at least one key
- LIMIT offset and count must be non-negative
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/48fc1243fc8e3503.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/CommandObjects.java:5280
try {
localRef = this.jsonObjectMapper;
if (Objects.isNull(localRef)) {
this.jsonObjectMapper = localRef = new DefaultGsonObjectMapper();
}
} finally {
mapperLock.unlock();
}
}
return localRef;
}
public void setJsonObjectMapper(JsonObjectMapper jsonObjectMapper) {
this.jsonObjectMapper = jsonObjectMapper;
}
public void setDefaultSearchDialect(int dialect) {
if (dialect == 0) throw new IllegalArgumentException("DIALECT=0 cannot be set.");
this.searchDialect.set(dialect);
}
private class SearchProfileResponseBuilder<T> extends Builder<Map.Entry<T, ProfilingInfo>> {
private static final String PROFILE_STR_REDIS7 = "profile";
private static final String PROFILE_STR_REDIS8 = "Profile";
private static final String RESULTS_STR_REDIS7 = "results";
private static final String RESULTS_STR_REDIS8 = "Results";
private final Builder<T> resultsBuilder;
public SearchProfileResponseBuilder(Builder<T> resultsBuilder) {
this.resultsBuilder = resultsBuilder;
}
@Override
public Map.Entry<T, ProfilingInfo> build(Object data) {View on GitHub (pinned to 6dac31d4c2)