{"record":{"id":"de8324ce35acf4f3","repo":"redis/jedis","slug":"dialect-0-cannot-be-set-de8324","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/DefaultJedisClientConfig.java","lineNumber":501,"sourceCode":"     */\n    public Builder jsonObjectMapper(JsonObjectMapper jsonObjectMapper) {\n      this.jsonObjectMapper = jsonObjectMapper;\n      return this;\n    }\n\n    /**\n     * Sets the default search dialect for RediSearch commands. Defaults to\n     * {@link SearchProtocol#DEFAULT_DIALECT}.\n     * <p>\n     * <b>Not honored by the legacy {@link Jedis} class</b> — only the {@link UnifiedJedis} family\n     * reads this value when constructing its command pipeline.\n     * @param searchDialect the dialect version (must not be 0)\n     * @return this\n     * @throws IllegalArgumentException if {@code searchDialect == 0}\n     */\n    public Builder searchDialect(int searchDialect) {\n      if (searchDialect == 0) {\n        throw new IllegalArgumentException(\"DIALECT=0 cannot be set.\");\n      }\n      this.searchDialect = searchDialect;\n      return this;\n    }\n\n    public Builder from(JedisClientConfig instance) {\n      this.redisProtocol = instance.getRedisProtocol();\n      this.autoNegotiateProtocol = instance.isAutoNegotiateProtocol();\n      this.connectionTimeoutMillis = instance.getConnectionTimeoutMillis();\n      this.socketTimeoutMillis = instance.getSocketTimeoutMillis();\n      this.blockingSocketTimeoutMillis = instance.getBlockingSocketTimeoutMillis();\n      this.credentialsProvider = instance.getCredentialsProvider();\n      this.database = instance.getDatabase();\n      this.clientName = instance.getClientName();\n      this.ssl = instance.isSsl();\n      this.sslSocketFactory = instance.getSslSocketFactory();\n      this.sslParameters = instance.getSslParameters();\n      this.sslOptions = instance.getSslOptions();","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/DefaultJedisClientConfig.java#L483-L519","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set an explicit dialect, e.g. .searchDialect(2) (or 1) in the client config","If 'server default' is desired, omit the searchDialect call entirely so the field stays unset","Fix config parsing so an absent/0 dialect maps to 'unset' rather than calling the setter with 0"],"exampleFix":"// before\nDefaultJedisClientConfig cfg = DefaultJedisClientConfig.builder()\n    .searchDialect(dialectFromProps) // 0 -> IllegalArgumentException\n    .build();\n// after\nDefaultJedisClientConfig.Builder b = DefaultJedisClientConfig.builder();\nif (dialectFromProps > 0) b.searchDialect(dialectFromProps);\nDefaultJedisClientConfig cfg = b.build();","handlingStrategy":"validation","validationCode":"if (searchDialect == 0) {\n  throw new IllegalArgumentException(\"searchDialect must be >= 1; omit the setter to use server default\");\n}\nbuilder.searchDialect(searchDialect);","typeGuard":null,"tryCatchPattern":"try {\n  builder.searchDialect(dialect);\n} catch (IllegalArgumentException e) {\n  // dialect was 0; fall back to server default (skip setter)\n}","preventionTips":["Treat 0 from config/env as 'unset' and skip the searchDialect call","Use explicit dialects (1 or 2) rather than sentinel zeros","Validate parsed config values before passing them into builders"],"tags":["java","jedis","search","configuration","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"}