{"record":{"id":"24e316a4fdc60101","repo":"redis/jedis","slug":"dialect-0-cannot-be-set-24e316","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/builders/AbstractClientBuilder.java","lineNumber":336,"sourceCode":"  /**\n   * Sets the default search dialect for RediSearch operations.\n   * <p>\n   * The search dialect determines the query syntax and features available for RediSearch commands.\n   * Different dialects support different query features and syntax variations.\n   * <p>\n   * Default is {@value redis.clients.jedis.search.SearchProtocol#DEFAULT_DIALECT}.\n   * @param searchDialect the search dialect version\n   * @return this builder\n   * @throws IllegalArgumentException if dialect is 0 (not allowed)\n   * @deprecated use {@link DefaultJedisClientConfig.Builder#searchDialect(int)} on the\n   *             {@link JedisClientConfig} passed via {@link #clientConfig(JedisClientConfig)}. When\n   *             this setter is used it is folded into the resulting client config at\n   *             {@link #build()} time.\n   */\n  @Deprecated\n  public T searchDialect(int searchDialect) {\n    if (searchDialect == 0) {\n      throw new IllegalArgumentException(\"DIALECT=0 cannot be set.\");\n    }\n    this.searchDialect = searchDialect;\n    return self();\n  }\n\n  /**\n   * Validates common configuration parameters.\n   * <p>\n   * This method can be called by concrete builders to validate the common configuration before\n   * building the client.\n   * @throws IllegalArgumentException if any common configuration is invalid\n   */\n  protected void validateCommonConfiguration() {\n    if (cache != null || cacheConfig != null) {\n      if (clientConfig != null && !canNegotiateResp3(clientConfig)) {\n        throw new IllegalArgumentException(\"Client-side caching is only supported with RESP3.\");\n      }\n    }","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/builders/AbstractClientBuilder.java#L318-L354","documentation":"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.","triggerScenarios":"Calling .searchDialect(0) on a RedisClient/RedisClusterClient builder, typically because a default/unset value (0) from a config field is passed through.","commonSituations":"Integer config field defaulting to 0 and passed unconditionally to the builder; misunderstanding that 0 means 'use server default' — instead omit the setter entirely.","solutions":["Pass a valid dialect (1, 2, or higher per your RediSearch version).","Omit the searchDialect() call to use the server default.","Guard the builder call: only invoke it when a positive dialect is configured."],"exampleFix":"// before\nbuilder.searchDialect(config.getSearchDialect()); // 0 default\n// after\nif (config.getSearchDialect() > 0) {\n  builder.searchDialect(config.getSearchDialect());\n}","handlingStrategy":"validation","validationCode":"if (dialect <= 0) throw new IllegalArgumentException(\"searchDialect must be >= 1\");","typeGuard":null,"tryCatchPattern":"try {\n  builder.searchDialect(dialect);\n} catch (IllegalArgumentException e) {\n  log.error(\"Invalid search dialect: {}\", e.getMessage());\n}","preventionTips":["Never pass 0; omit the setter for server default","Validate config values before mapping into builders","Guard optional setters with positive-value checks"],"tags":["search","configuration","validation","jedis"],"backgroundTag":"invalid-config-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"}