redis/jedis · error · IllegalArgumentException
Must have at least one tag
Error message
Must have at least one tag
What it means
Values.tags(String... tags) builds a RediSearch tag-filter Value from one or more tag strings. Because a tag filter with zero tags is meaningless in RediSearch query syntax, the method rejects an empty varargs array with IllegalArgumentException("Must have at least one tag").
Solutions
- Guard the call site: only call Values.tags when the tag array is non-empty.
- Skip adding the tag filter node entirely when the list is empty.
- If at least one tag is always required by your domain, validate input earlier (e.g. at request parsing) with a clearer message.
Example fix
// before
Query.Node n = new QueryBuilder().addFilter(Values.tags(selectedTags.toArray(new String[0])));
// after
if (!selectedTags.isEmpty()) {
qb.addFilter(Values.tags(selectedTags.toArray(new String[0])));
} Defensive patterns
Strategy: validation
Validate before calling
if (tags == null || tags.length == 0) {
throw new IllegalArgumentException("At least one tag is required for a tag filter");
}
Value v = Values.tags(tags); Type guard
boolean hasTags(String[] tags) {
return tags != null && tags.length > 0;
} Try / catch
try {
value = Values.tags(tagArray);
} catch (IllegalArgumentException e) {
log.warn("Skipping empty tag filter: {}", e.getMessage());
} Prevention
- Always check the tag array is non-empty before calling Values.tags.
- Skip adding tag filter nodes when the tag list is empty.
- Validate tag selection at the API/UI boundary so empty lists never reach query construction.
When it happens
Trigger: Calling Values.tags() with no arguments, or passing an empty String[] / empty collection converted to an array (e.g. Values.tags(myList.toArray(new String[0])) where the list is empty).
Common situations: Building tag filters from user-selected filter chips or request parameters where the user selected none; dynamic query construction where an empty tags list flows into Values.tags instead of being skipped.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- DriverInfo must not be null
- DIALECT=0 cannot be set.
- DIALECT=0 cannot be set.
- REDUCE COLLECT cannot mix FIELDS * with explicit field names
- Must not instantiate this class
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/9b8ef323fd7e5156.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/search/querybuilder/Values.java:90
public static RangeValue le(double d) {
return lt(d).inclusiveMax(true);
}
public static RangeValue le(int d) {
return lt(d).inclusiveMax(true);
}
public static RangeValue ge(double d) {
return gt(d).inclusiveMin(true);
}
public static RangeValue ge(int d) {
return gt(d).inclusiveMin(true);
}
public static Value tags(String... tags) {
if (tags.length == 0) {
throw new IllegalArgumentException("Must have at least one tag");
}
StringJoiner sj = new StringJoiner(" | ");
for (String s : tags) {
sj.add(s);
}
return new Value() {
@Override
public String toString() {
return "{" + sj.toString() + "}";
}
};
}
}
View on GitHub (pinned to 6dac31d4c2)