quarkusio/quarkus · error · IllegalArgumentException
`pattern` must not be `null`
Error message
`pattern` must not be `null`
What it means
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.
Source
Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/ScanArgs.java:36
* @return the current {@code ScanArgs}
*/
public ScanArgs count(long count) {
if (count <= 0) {
throw new IllegalArgumentException("`count` must be strictly positive");
}
this.count = count;
return this;
}
/**
* Sets a {@code MATCH} pattern
*
* @param pattern the pattern, must not be {@code null}
* @return the current {@code ScanArgs}
*/
public ScanArgs match(String pattern) {
if (pattern == null) {
throw new IllegalArgumentException("`pattern` must not be `null`");
}
this.match = pattern;
return this;
}
public List<String> toArgs() {
List<String> args = new ArrayList<>();
if (this.count != -1) {
args.add("COUNT");
args.add(Long.toString(this.count));
}
if (this.match != null) {
args.add("MATCH");
args.add(this.match);
}
return args;
}
}View on GitHub (pinned to e1c734241f)
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
Example fix
// before
String pattern = config.pattern(); // may be null
args.match(pattern);
// after
String pattern = config.pattern();
if (pattern != null) {
args.match(pattern);
} Defensive patterns
Strategy: validation
Validate before calling
if (pattern == null) { throw new IllegalArgumentException("pattern required"); }
args.match(pattern); Type guard
static boolean isValidPattern(String p) { return p != null && !p.isEmpty(); } Try / catch
try { args.match(pattern); } catch (IllegalArgumentException e) { args = new ScanArgs(); /* fallback to no MATCH */ } Prevention
- Default missing patterns to "*"
- Validate config-supplied patterns at startup
- Never pass Optional-wrapped values without unwrapping
When it happens
Trigger: 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.
Common situations: Configuration property for a scan pattern not set; a lookup map returning null for a pattern; refactoring where the pattern variable became Optional/null.
Related errors
- `timeout` must not be `null`
- `timestamp` must not be `null`
- Invalid integer encoding for a bit field type: " + bit + ".
- `bits` must be strictly positive
- Signed integers support only up to 64 bits
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/ee5c80c6d168564f.
Report an issue: GitHub.