alibaba/Sentinel · error · IllegalArgumentException
Invalid object: null
Error message
Invalid object: null
What it means
Thrown by the static factory ParamFlowItem.newItem(object, count) when object is null. A ParamFlowItem stores the hot-parameter threshold as object.toString() plus its class type, so a null parameter has neither representation; the factory rejects it before creating a meaningless item.
Source
Thrown at sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowItem.java:41
* @since 0.2.0
*/
public class ParamFlowItem {
private String object;
private Integer count;
private String classType;
public ParamFlowItem() {}
public ParamFlowItem(String object, Integer count, String classType) {
this.object = object;
this.count = count;
this.classType = classType;
}
public static <T> ParamFlowItem newItem(T object, Integer count) {
if (object == null) {
throw new IllegalArgumentException("Invalid object: null");
}
return new ParamFlowItem(object.toString(), count, object.getClass().getName());
}
public String getObject() {
return object;
}
public ParamFlowItem setObject(String object) {
this.object = object;
return this;
}
public Integer getCount() {
return count;
}
public ParamFlowItem setCount(Integer count) {View on GitHub (pinned to a3f40ba8e9)
Solutions
- Ensure the parameter object is non-null before calling newItem; skip or default the entry when the source value is null.
- If the value comes from a map, check containsKey/get != null first and log which key was missing.
- Note newItem uses object.toString() and getClass().getName() — use a primitive wrapper/String or a type with a meaningful toString().
Example fix
// before
ParamFlowItem item = ParamFlowItem.newItem(paramMap.get("userId"), 10); // null when key absent
// after
Object userId = paramMap.get("userId");
if (userId == null) { throw new IllegalArgumentException("paramMap missing userId"); }
ParamFlowItem item = ParamFlowItem.newItem(userId, 10); Defensive patterns
Strategy: validation
Validate before calling
public static ParamFlowItem safeNewItem(Object param, Integer count) {
if (param == null) {
throw new IllegalArgumentException("hot parameter must not be null");
}
return ParamFlowItem.newItem(param, count);
} Try / catch
try {
items.add(ParamFlowItem.newItem(param, count));
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().contains("Invalid object")) {
log.warn("skipping hot-param rule for null parameter");
return; // or apply a default
}
throw e;
} Prevention
- Null-check map lookups and request attributes before building ParamFlowItem entries.
- Prefer primitive wrappers/String parameters with meaningful toString() for hot-param rules.
When it happens
Trigger: ParamFlowItem.newItem(null, count) — usually a parameter value that came back null from a map lookup, request attribute, or configuration (e.g. paramMap.get("user") returning null for an absent key) and is forwarded to newItem without a null check.
Common situations: Building ParameterFlowRule entities programmatically from user input or config maps where a key may be absent; deserializing rules where a field was optional; unit tests passing null accidentally.
Related errors
- Config encoder cannot be null
- File can't be null or a directory
- charset can't be null
- ${filePath} file size=${fileSize}, is bigger than bufSize=${
- Bad file
AI-assisted analysis of alibaba/Sentinel@a3f40ba8e9 (2026-08-14).
Data as JSON: /api/errors/2cb2f6c796e8cb83.
Report an issue: GitHub.