{"record":{"id":"1e9a606182d5e950","repo":"quarkusio/quarkus","slug":"cannot-use-maxlen-and-minid-together-1e9a60","errorCode":null,"errorMessage":"Cannot use `MAXLEN` and `MINID` together","messagePattern":"Cannot use `MAXLEN` and `MINID` together","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/stream/XTrimArgs.java","lineNumber":71,"sourceCode":"\n    /**\n     * Sets the maximum entries that can get evicted.\n     *\n     * @param limit the limit, must be positive\n     * @return the current {@code XAddArgs}\n     */\n    public XTrimArgs limit(long limit) {\n        this.limit = limit;\n        return this;\n    }\n\n    @Override\n    public List<Object> toArgs() {\n        List<Object> args = new ArrayList<>();\n\n        if (maxlen >= 0) {\n            if (minid != null) {\n                throw new IllegalArgumentException(\"Cannot use `MAXLEN` and `MINID` together\");\n            }\n\n            args.add(\"MAXLEN\");\n            if (approximateTrimming) {\n                args.add(\"~\");\n            } else {\n                args.add(\"=\");\n            }\n            args.add(Long.toString(maxlen));\n        }\n\n        if (minid != null) {\n            args.add(\"MINID\");\n            if (approximateTrimming) {\n                args.add(\"~\");\n            } else {\n                args.add(\"=\");\n            }","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/stream/XTrimArgs.java#L53-L89","documentation":"XTRIM supports two mutually exclusive trimming strategies: MAXLEN (trim by entry count) and MINID (trim by entry ID threshold). The Redis protocol does not allow both in one command, so XTrimArgs.toArgs() throws this IllegalArgumentException when both maxlen(long) and minid(String) have been set on the same args object.","triggerScenarios":"Calling XTrimArgs.builder-style chaining that sets both, e.g. new XTrimArgs().maxlen(1000).minid(\"1234-0\"), then passing it to streamCommands.xtrim(key, args) — the error surfaces at toArgs() time when the command arguments are built.","commonSituations":"Building args from configuration where both a max-length and a min-ID policy are configured (e.g. both properties set in application config), or refactoring from a MAXLEN policy to MINID without removing the maxlen(...) call.","solutions":["Remove either the maxlen(...) or the minid(...) call so only one trimming strategy is set","If both policies come from config, enforce a single strategy choice before constructing XTrimArgs","Pick the strategy matching your semantics: maxlen for entry-count caps, minid for time/ID-based eviction"],"exampleFix":"// before\nXTrimArgs args = new XTrimArgs().maxlen(1000).minid(\"1526505285000-0\");\n// after\nXTrimArgs args = new XTrimArgs().minid(\"1526505285000-0\");","handlingStrategy":"validation","validationCode":"if (args.maxlen >= 0 && args.minid != null) {\n    throw new IllegalArgumentException(\"Configure either maxlen or minid for XTRIM, not both\");\n}","typeGuard":"boolean isValidTrimArgs(XTrimArgs a) {\n    return a != null;\n}","tryCatchPattern":"try {\n    streamCommands.xtrim(key, args);\n} catch (IllegalArgumentException e) {\n    log.error(\"Invalid XTRIM args: \" + e.getMessage());\n}","preventionTips":["Set exactly one trimming strategy (maxlen or minid) per XTrimArgs object","If both policies are configurable, validate config at startup and fail fast","Prefer building args in a single helper method so conflicting setters cannot be mixed"],"tags":["redis","streams","xtrim","invalid-arguments"],"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-14T05:17:10.506Z"}