{"record":{"id":"48fc1243fc8e3503","repo":"redis/jedis","slug":"dialect-0-cannot-be-set","errorCode":null,"errorMessage":"DIALECT=0 cannot be set.","messagePattern":"DIALECT=0 cannot be set\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/CommandObjects.java","lineNumber":5280,"sourceCode":"\n      try {\n        localRef = this.jsonObjectMapper;\n        if (Objects.isNull(localRef)) {\n          this.jsonObjectMapper = localRef = new DefaultGsonObjectMapper();\n        }\n      } finally {\n        mapperLock.unlock();\n      }\n    }\n    return localRef;\n  }\n\n  public void setJsonObjectMapper(JsonObjectMapper jsonObjectMapper) {\n    this.jsonObjectMapper = jsonObjectMapper;\n  }\n\n  public void setDefaultSearchDialect(int dialect) {\n    if (dialect == 0) throw new IllegalArgumentException(\"DIALECT=0 cannot be set.\");\n    this.searchDialect.set(dialect);\n  }\n\n  private class SearchProfileResponseBuilder<T> extends Builder<Map.Entry<T, ProfilingInfo>> {\n\n    private static final String PROFILE_STR_REDIS7 = \"profile\";\n    private static final String PROFILE_STR_REDIS8 = \"Profile\";\n    private static final String RESULTS_STR_REDIS7 = \"results\";\n    private static final String RESULTS_STR_REDIS8 = \"Results\";\n\n    private final Builder<T> resultsBuilder;\n\n    public SearchProfileResponseBuilder(Builder<T> resultsBuilder) {\n      this.resultsBuilder = resultsBuilder;\n    }\n\n    @Override\n    public Map.Entry<T, ProfilingInfo> build(Object data) {","sourceCodeStart":5262,"sourceCodeEnd":5298,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/CommandObjects.java#L5262-L5298","documentation":"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.","triggerScenarios":"Calling setDefaultSearchDialect(0), typically with a variable that defaulted to 0 (uninitialized int) or a config value of 0 meaning 'auto'.","commonSituations":"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.","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"],"exampleFix":"// before\nint dialect = Integer.parseInt(props.getProperty(\"search.dialect\", \"0\"));\nco.setDefaultSearchDialect(dialect); // 0 -> throw\n// after\nint dialect = Integer.parseInt(props.getProperty(\"search.dialect\", \"0\"));\nif (dialect != 0) co.setDefaultSearchDialect(dialect);","handlingStrategy":"validation","validationCode":"if (dialect < 1 || dialect > 3) throw new IllegalArgumentException(\"search dialect must be 1, 2 or 3\");","typeGuard":"static boolean isValidDialect(int d) { return d == 1 || d == 2 || d == 3; }","tryCatchPattern":"try { co.setDefaultSearchDialect(d); } catch (IllegalArgumentException e) { log.warn(\"ignoring invalid dialect \" + d); }","preventionTips":["Treat 0 as 'unset' and skip the setter","Validate config-sourced dialects at load time","Default to dialect 2 when unset"],"tags":["jedis","redis-search","dialect","argument-validation"],"backgroundTag":"invalid-argument-value","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"}