{"record":{"id":"659841b369a29efe","repo":"redis/jedis","slug":"must-choose-exactly-one-filter-in-classname","errorCode":null,"errorMessage":"Must choose exactly one filter in ${className}","messagePattern":"Must choose exactly one filter in (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/params/CommandListFilterByParams.java","lineNumber":47,"sourceCode":"    this.pattern = pattern;\n    return this;\n  }\n\n  @Override\n  public void addParams(CommandArguments args) {\n    args.add(Keyword.FILTERBY);\n\n    if (moduleName != null && category == null && pattern == null) {\n      args.add(Keyword.MODULE);\n      args.add(moduleName);\n    } else if (moduleName == null && category != null && pattern == null) {\n      args.add(Keyword.ACLCAT);\n      args.add(category);\n    } else if (moduleName == null && category == null && pattern != null) {\n      args.add(Keyword.PATTERN);\n      args.add(pattern);\n    } else {\n      throw new IllegalArgumentException(\"Must choose exactly one filter in \"\n          + getClass().getSimpleName());\n    }\n  }\n\n  @Override\n  public boolean equals(Object o) {\n    if (this == o) return true;\n    if (o == null || getClass() != o.getClass()) return false;\n    CommandListFilterByParams that = (CommandListFilterByParams) o;\n    return Objects.equals(moduleName, that.moduleName) && Objects.equals(category, that.category) && Objects.equals(pattern, that.pattern);\n  }\n\n  @Override\n  public int hashCode() {\n    return Objects.hash(moduleName, category, pattern);\n  }\n}\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/params/CommandListFilterByParams.java#L29-L65","documentation":"COMMAND LIST FILTERBY accepts exactly one filter (MODULE, ACLCAT, or PATTERN). CommandListFilterByParams.addParams validates that precisely one of moduleName, category, or pattern was set; if none or more than one is set, it throws IllegalArgumentException naming the concrete class via getClass().getSimpleName().","triggerScenarios":"Calling CommandListFilterByParams with: no filter at all; both MODULE and ACLCAT; both MODULE and PATTERN; both ACLCAT and PATTERN; or all three set.","commonSituations":"Composing filters from user input where several optional filter fields are populated; copying a params builder and adding a second filter; generic param-passing code that sets defaults for multiple filter fields.","solutions":["Set exactly one of module(), aclCat(), or pattern() before passing the params object to COMMAND LIST FILTERBY.","If multiple filters come from user input, validate/whitelist to a single filter before building the params.","Issue separate COMMAND LIST FILTERBY calls (one per filter) and merge the results in application code if multiple criteria are needed."],"exampleFix":"// before\nCommandListFilterByParams params = CommandListFilterByParams.CommandListFilterByParamsBuilder\n    .module(\"search\").pattern(\"foo*\").build(); // two filters -> error\n// after\nCommandListFilterByParams params = CommandListFilterByParams.CommandListFilterByParamsBuilder\n    .pattern(\"foo*\").build(); // exactly one filter","handlingStrategy":"validation","validationCode":"int set = (moduleName != null ? 1 : 0) + (category != null ? 1 : 0) + (pattern != null ? 1 : 0);\nif (set != 1) throw new IllegalArgumentException(\"choose exactly one of module/aclCat/pattern\");","typeGuard":null,"tryCatchPattern":"try {\n  jedis.commandListFilterBy(params);\n} catch (IllegalArgumentException e) {\n  log.error(\"FILTERBY params invalid: {}\", e.getMessage());\n}","preventionTips":["Expose only one filter field in your UI/config for FILTERBY.","Build exactly one branch when composing filters from user input.","Unit-test params builders with each single-filter combination and reject multi-filter inputs."],"tags":["params","filterby","illegal-argument","command-list"],"backgroundTag":"mutually-exclusive-flags","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"}