{"record":{"id":"2557911558e541bc","repo":"flowable/flowable-engine","slug":"state-is-null","errorCode":null,"errorMessage":"state is null","messagePattern":"state is null","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java","lineNumber":676,"sourceCode":"\n    @Override\n    public HistoricCaseInstanceQueryImpl finishedBy(String userId) {\n        if (userId == null) {\n            throw new FlowableIllegalArgumentException(\"user id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.finishedBy = userId;\n        } else {\n            this.finishedBy = userId;\n        }\n\n        return this;\n    }\n    \n    @Override\n    public HistoricCaseInstanceQueryImpl state(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\n        return this;\n    }\n\n    @Override\n    public HistoricCaseInstanceQuery lastReactivatedBefore(Date beforeTime) {\n        if (beforeTime == null) {\n            throw new FlowableIllegalArgumentException(\"before time is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.lastReactivatedBefore = beforeTime;\n        } else {","sourceCodeStart":658,"sourceCodeEnd":694,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java#L658-L694","documentation":"HistoricCaseInstanceQueryImpl.state() is a query-builder setter for the case instance state (e.g. 'active', 'completed', 'terminated'). The Flowable CMMN engine throws FlowableIllegalArgumentException immediately when the argument is null because a null state can never be translated into a meaningful SQL predicate. This is fail-fast input validation, not a runtime failure of the engine.","triggerScenarios":"Calling historicCaseInstanceQuery.state(null) directly, or passing a variable that resolves to null (e.g. an unset request parameter or config value) into state().","commonSituations":"Web/UI code binding a state filter from a request parameter that was never supplied; deserializing query options from JSON where the state key is absent; refactoring where a constant holding the state became null.","solutions":["Ensure a non-null state value (e.g. \"active\", \"completed\", \"terminated\") is passed to state().","If the state filter is optional, skip calling state() entirely instead of calling it with null.","Validate/sanitize the input (e.g. map empty or 'any' UI values to skipping the filter) before building the query.","Catch FlowableIllegalArgumentException if input is user-supplied and return a 400-style validation message."],"exampleFix":"// before\nString state = request.getParameter(\"state\"); // may be null\nquery.state(state);\n\n// after\nString state = request.getParameter(\"state\");\nif (state != null && !state.isEmpty()) {\n    query.state(state);\n}","handlingStrategy":"validation","validationCode":"if (state != null) {\n    query.state(state);\n}","typeGuard":"boolean hasState = s -> s != null && !s.trim().isEmpty();","tryCatchPattern":"try {\n    query.state(state);\n} catch (FlowableIllegalArgumentException e) {\n    throw new IllegalArgumentException(\"Invalid state filter: \" + e.getMessage());\n}","preventionTips":["Treat state() as optional: only call it when a concrete state is selected.","Centralize query building in a helper that skips null filters.","Validate UI/request inputs at the boundary (non-empty, allowed values: active/completed/terminated).","Never rely on the engine to null-check user input."],"tags":["null-argument","query-builder","cmmn","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"}