{"record":{"id":"ee5c80c6d168564f","repo":"quarkusio/quarkus","slug":"pattern-must-not-be-null","errorCode":null,"errorMessage":"`pattern` must not be `null`","messagePattern":"`pattern` must not be `null`","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/ScanArgs.java","lineNumber":36,"sourceCode":"     * @return the current {@code ScanArgs}\n     */\n    public ScanArgs count(long count) {\n        if (count <= 0) {\n            throw new IllegalArgumentException(\"`count` must be strictly positive\");\n        }\n        this.count = count;\n        return this;\n    }\n\n    /**\n     * Sets a {@code MATCH} pattern\n     *\n     * @param pattern the pattern, must not be {@code null}\n     * @return the current {@code ScanArgs}\n     */\n    public ScanArgs match(String pattern) {\n        if (pattern == null) {\n            throw new IllegalArgumentException(\"`pattern` must not be `null`\");\n        }\n        this.match = pattern;\n        return this;\n    }\n\n    public List<String> toArgs() {\n        List<String> args = new ArrayList<>();\n        if (this.count != -1) {\n            args.add(\"COUNT\");\n            args.add(Long.toString(this.count));\n        }\n        if (this.match != null) {\n            args.add(\"MATCH\");\n            args.add(this.match);\n        }\n        return args;\n    }\n}","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/ScanArgs.java#L18-L54","documentation":"ScanArgs.match() is a fluent builder for the Redis SCAN MATCH pattern argument. The library validates its inputs eagerly and throws IllegalArgumentException when the pattern is null, because a null MATCH pattern cannot be encoded into the Redis command and would indicate a caller bug.","triggerScenarios":"Calling ScanArgs.match(null) directly, or passing a variable that failed to initialize (e.g. a null config property or user-supplied pattern) into match() while building args for scan/keys-style commands.","commonSituations":"Configuration property for a scan pattern not set; a lookup map returning null for a pattern; refactoring where the pattern variable became Optional/null.","solutions":["Ensure the pattern passed to match() is non-null before building ScanArgs","Default the pattern to \"*\" (match all) when no specific pattern is configured","If the pattern is optional, skip calling match() entirely instead of passing null"],"exampleFix":"// before\nString pattern = config.pattern(); // may be null\nargs.match(pattern);\n// after\nString pattern = config.pattern();\nif (pattern != null) {\n    args.match(pattern);\n}","handlingStrategy":"validation","validationCode":"if (pattern == null) { throw new IllegalArgumentException(\"pattern required\"); }\nargs.match(pattern);","typeGuard":"static boolean isValidPattern(String p) { return p != null && !p.isEmpty(); }","tryCatchPattern":"try { args.match(pattern); } catch (IllegalArgumentException e) { args = new ScanArgs(); /* fallback to no MATCH */ }","preventionTips":["Default missing patterns to \"*\"","Validate config-supplied patterns at startup","Never pass Optional-wrapped values without unwrapping"],"tags":["redis","argument-validation","null-check"],"backgroundTag":"null-argument-validation","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"}