{"record":{"id":"2cb2f6c796e8cb83","repo":"alibaba/Sentinel","slug":"invalid-object-null","errorCode":null,"errorMessage":"Invalid object: null","messagePattern":"Invalid object: null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowItem.java","lineNumber":41,"sourceCode":" * @since 0.2.0\n */\npublic class ParamFlowItem {\n\n    private String object;\n    private Integer count;\n    private String classType;\n\n    public ParamFlowItem() {}\n\n    public ParamFlowItem(String object, Integer count, String classType) {\n        this.object = object;\n        this.count = count;\n        this.classType = classType;\n    }\n\n    public static <T> ParamFlowItem newItem(T object, Integer count) {\n        if (object == null) {\n            throw new IllegalArgumentException(\"Invalid object: null\");\n        }\n        return new ParamFlowItem(object.toString(), count, object.getClass().getName());\n    }\n\n    public String getObject() {\n        return object;\n    }\n\n    public ParamFlowItem setObject(String object) {\n        this.object = object;\n        return this;\n    }\n\n    public Integer getCount() {\n        return count;\n    }\n\n    public ParamFlowItem setCount(Integer count) {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/alibaba/Sentinel/blob/a3f40ba8e900c8489bd520274739f17235a7721c/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowItem.java#L23-L59","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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()."],"exampleFix":"// before\nParamFlowItem item = ParamFlowItem.newItem(paramMap.get(\"userId\"), 10); // null when key absent\n\n// after\nObject userId = paramMap.get(\"userId\");\nif (userId == null) { throw new IllegalArgumentException(\"paramMap missing userId\"); }\nParamFlowItem item = ParamFlowItem.newItem(userId, 10);","handlingStrategy":"validation","validationCode":"public static ParamFlowItem safeNewItem(Object param, Integer count) {\n    if (param == null) {\n        throw new IllegalArgumentException(\"hot parameter must not be null\");\n    }\n    return ParamFlowItem.newItem(param, count);\n}","typeGuard":null,"tryCatchPattern":"try {\n    items.add(ParamFlowItem.newItem(param, count));\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Invalid object\")) {\n        log.warn(\"skipping hot-param rule for null parameter\");\n        return; // or apply a default\n    }\n    throw e;\n}","preventionTips":["Null-check map lookups and request attributes before building ParamFlowItem entries.","Prefer primitive wrappers/String parameters with meaningful toString() for hot-param rules."],"tags":["sentinel","param-flow-control","null-argument","hot-param","java"],"backgroundTag":null,"analyzedSha":"a3f40ba8e900c8489bd520274739f17235a7721c","analyzedAt":"2026-08-14T11:10:30.678Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}