redis/jedis · error · IllegalArgumentException
Setting null as field attribute is not allowed.
Error message
Setting null as field attribute is not allowed.
What it means
FieldName.as(attribute) renames a search index field (the AS clause in FT.CREATE/FT.ALTER). Passing null as the attribute name is rejected with IllegalArgumentException because a null alias has no meaning in the RediSearch protocol.
Solutions
- Ensure the alias string is non-null before calling as(), e.g. throw or skip aliasing when absent
- Only call as() when an alias is actually configured: if (alias != null) field.as(alias);
- Validate schema configuration at startup before constructing FieldName objects
Example fix
// before
fields.add(new FieldName(rawName).as(config.get("alias")));
// after
String alias = config.get("alias");
FieldName f = new FieldName(rawName);
if (alias != null) f.as(alias);
fields.add(f); Defensive patterns
Strategy: validation
Validate before calling
if (alias != null) {
fieldName.as(alias);
} Type guard
Optional.ofNullable(alias).ifPresent(fieldName::as);
Prevention
- Validate schema/alias configuration at startup
- Never pass Optional.orElse(null) results into as()
- Only call as() when aliasing is actually configured
When it happens
Trigger: Calling new FieldName("my_field").as(someString) where someString is null, often from a nullable config value or a map key derived dynamically.
Common situations: Building index schemas from configuration files where an alias key is absent; passing Optional-unwrapped nulls; framework code that forwards null attributes.
Related errors
- Attribute for this field is already set.
- A null argument cannot be sent to Redis.
- Unrecognized header
- protocol must not be null
- DIALECT=0 cannot be set.
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/7b7f6338b10ddc34.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/search/FieldName.java:24
import redis.clients.jedis.search.SearchProtocol.SearchKeyword;
public class FieldName implements IParams {
private final String name;
private String attribute;
public FieldName(String name) {
this.name = name;
}
public FieldName(String name, String attribute) {
this.name = name;
this.attribute = attribute;
}
public FieldName as(String attribute) {
if (attribute == null) {
throw new IllegalArgumentException("Setting null as field attribute is not allowed.");
}
if (this.attribute != null) {
throw new IllegalStateException("Attribute for this field is already set.");
}
this.attribute = attribute;
return this;
}
public final String getName() {
return name;
}
public final String getAttribute() {
return attribute;
}
public int addCommandArguments(List<Object> args) {
args.add(name);View on GitHub (pinned to 6dac31d4c2)