{"record":{"id":"7ff38355fd57db80","repo":"flowable/flowable-engine","slug":"state-is-null-7ff383","errorCode":null,"errorMessage":"State is null","messagePattern":"State is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/PlanItemInstanceQueryImpl.java","lineNumber":274,"sourceCode":"    }\n\n    @Override\n    public PlanItemInstanceQuery planItemInstanceName(String name) {\n        if (name == null) {\n            throw new FlowableIllegalArgumentException(\"Name is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.name = name;\n        } else {\n            this.name = name;\n        }\n        return this;\n    }\n\n    @Override\n    public PlanItemInstanceQuery planItemInstanceState(String state) {\n        if (state == null) {\n            throw new FlowableIllegalArgumentException(\"State is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.state = state;\n        } else {\n            this.state = state;\n        }\n        return this;\n    }\n    \n    @Override\n    public PlanItemInstanceQuery planItemInstanceStateWaitingForRepetition() {\n        return planItemInstanceState(PlanItemInstanceState.WAITING_FOR_REPETITION);\n    }\n    \n    @Override\n    public PlanItemInstanceQuery planItemInstanceStateActive() {\n        return planItemInstanceState(PlanItemInstanceState.ACTIVE);\n    }","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/PlanItemInstanceQueryImpl.java#L256-L292","documentation":"Thrown by PlanItemInstanceQueryImpl.planItemInstanceState when the state filter is null. State must be one of the PlanItemInstanceState constants (e.g. 'active', 'enabled', 'available'). This method is also the backing implementation for the convenience methods (planItemInstanceStateActive, planItemInstanceStateEnabled, etc.), so those never hit this error — only direct calls with null do.","triggerScenarios":"Calling planItemInstanceState(null) directly, or passing a state variable resolved from config/DB/request that is null.","commonSituations":"Mapping an absent 'state' filter parameter into the query; passing a null from an enum lookup that failed (e.g. Enum.valueOf miss handled by returning null).","solutions":["Pass a valid state constant, e.g. PlanItemInstanceState.ACTIVE.","Use the typed convenience methods (planItemInstanceStateActive(), planItemInstanceStateEnabled(), ...) instead of hand-built strings.","Null-check the resolved state and skip the filter if absent."],"exampleFix":"// before\nquery.planItemInstanceState(stateParam); // stateParam may be null\n// after\nif (stateParam != null) {\n    query.planItemInstanceState(stateParam);\n}\n// or, for known states:\nquery.planItemInstanceStateActive();","handlingStrategy":"validation","validationCode":"if (state != null) {\n    if (!PlanItemInstanceState.ALL_STATES.contains(state)) {\n        throw new IllegalArgumentException(\"Unknown plan item instance state: \" + state);\n    }\n    planItemInstanceQuery.planItemInstanceState(state);\n}","typeGuard":"boolean isValidState(String s) {\n    return s != null && PlanItemInstanceState.ALL_STATES.contains(s);\n}","tryCatchPattern":"try {\n    query.planItemInstanceState(state);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().equals(\"State is null\")) {\n        // omit the state filter or reject the request\n    } else {\n        throw e;\n    }\n}","preventionTips":["Use PlanItemInstanceState constants or the convenience methods (planItemInstanceStateActive, etc.) instead of raw strings","Validate state names against PlanItemInstanceState before querying","Never map a failed enum lookup to null; fail with a clear message instead"],"tags":["cmmn","query","null-argument","state","flowable"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}