{"record":{"id":"85f179b55864d02b","repo":"quarkusio/quarkus","slug":"cannot-specify-both-includes-and-excludes-term","errorCode":null,"errorMessage":"Cannot specify both `includes` and `excludes` terms","messagePattern":"Cannot specify both `includes` and `excludes` terms","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/search/SpellCheckArgs.java","lineNumber":79,"sourceCode":"     *\n     * @param dialect the dialect\n     * @return the current {@code SpellCheckArgs}\n     */\n    public SpellCheckArgs dialect(int dialect) {\n        this.dialect = dialect;\n        return this;\n    }\n\n    @Override\n    public List<Object> toArgs() {\n        List<Object> list = new ArrayList<>();\n        if (distance != 0) {\n            list.add(\"DISTANCE\");\n            list.add(Integer.toString(distance));\n        }\n\n        if (!includes.isEmpty() && !excludes.isEmpty()) {\n            throw new IllegalArgumentException(\"Cannot specify both `includes` and `excludes` terms\");\n        }\n        if (!includes.isEmpty()) {\n            list.add(\"TERMS\");\n            list.add(\"INCLUDE\");\n            list.addAll(includes);\n        } else if (!excludes.isEmpty()) {\n            list.add(\"TERMS\");\n            list.add(\"EXCLUDE\");\n            list.addAll(excludes);\n        }\n\n        if (dialect != -1) {\n            list.add(\"DIALECT\");\n            list.add(Integer.toString(dialect));\n        }\n\n        return list;\n    }","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/search/SpellCheckArgs.java#L61-L97","documentation":"FT.SPELLCHECK's TERMS option accepts either INCLUDE or EXCLUDE, not both in one command. The library models includes and excludes as two separate lists on SpellCheckArgs and throws in toArgs() if both are populated, since Redis could not accept the combined command.","triggerScenarios":"Building one SpellCheckArgs where both includes(...) and excludes(...) have been called with non-empty term collections, then serializing via toArgs().","commonSituations":"Collecting dictionaries/hints from configuration where both include and exclude lists are populated by default; merging two arg builders and keeping both lists.","solutions":["Populate only one of includes() or excludes() per SpellCheckArgs","Decide intent: to restrict suggestions use INCLUDE; to blacklist terms use EXCLUDE","Filter out empty list so only the non-empty one is applied"],"exampleFix":"// before\nSpellCheckArgs args = new SpellCheckArgs().includes(\"dict1\").excludes(\"badword\");\n// after\nSpellCheckArgs args = new SpellCheckArgs().includes(\"dict1\");","handlingStrategy":"validation","validationCode":"if (!includes.isEmpty() && !excludes.isEmpty()) throw new IllegalStateException(\"Use INCLUDE or EXCLUDE, not both\");","typeGuard":null,"tryCatchPattern":"try {\n    redis.search().spellcheck(...).toArgs();\n} catch (IllegalArgumentException e) {\n    // rebuild args with only one TERMS direction\n}","preventionTips":["Model the include/exclude choice as a single enum-backed field, not two lists","Zero out one list when the other is populated","Only populate TERMS lists from mutually exclusive config branches"],"tags":["redis","redisearch","mutually-exclusive-options","spellcheck"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}