{"record":{"id":"756969fb0e868028","repo":"quarkusio/quarkus","slug":"cannot-use-maxlen-and-minid-together","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/XAddArgs.java","lineNumber":104,"sourceCode":"     *\n     * @param limit the limit, must be positive\n     * @return the current {@code XAddArgs}\n     */\n    public XAddArgs 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        if (nomkstream) {\n            args.add(\"NOMKSTREAM\");\n        }\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":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/stream/XAddArgs.java#L86-L122","documentation":"XADD supports stream trimming either by count (MAXLEN) or by minimum ID (MINID), never both. XAddArgs.toArgs() throws IllegalArgumentException when a maxlen > 0 was set and a minid is also present, since Redis cannot accept both trim strategies in one command.","triggerScenarios":"Calling xAddArgs().maxlen(n) and .minId(id) on the same instance, then executing xadd; or reusing an XAddArgs where maxlen was set earlier and minid added later.","commonSituations":"Trim policy switched from count-based to ID-based but the old maxlen() call remains; merging default args (maxlen) with request-specific args (minid).","solutions":["Remove one of the two: keep maxlen(n) for count-based trimming or minId(id) for ID-based trimming","Create a fresh XAddArgs per publish instead of reusing one","Centralize trim policy in one code path so only one strategy is applied"],"exampleFix":"// before\nXAddArgs args = new XAddArgs().maxlen(1000).minId(\"1600000000000-0\");\n// after\nXAddArgs args = new XAddArgs().maxlen(1000);","handlingStrategy":"validation","validationCode":"if (maxLen > 0 && minId != null) throw new IllegalArgumentException(\"Use MAXLEN or MINID for XADD trimming, not both\");","typeGuard":null,"tryCatchPattern":"try {\n    stream.xadd(key, args, entries);\n} catch (IllegalArgumentException e) {\n    // rebuild XAddArgs with a single trim strategy\n}","preventionTips":["Centralize trimming policy in one place; switch strategy, don't stack options","Never reuse a mutated XAddArgs across publishes","Model trim strategy as a sealed/enum option (MaxLen or MinId), not two fields"],"tags":["redis","streams","mutually-exclusive-options","xadd","trimming"],"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-14T00:17:10.932Z"}