{"record":{"id":"7a2e8fc7f2279ded","repo":"flowable/flowable-engine","slug":"userid-is-null","errorCode":null,"errorMessage":"userId is null","messagePattern":"userId 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":1095,"sourceCode":"    }\n\n    @Override\n    public HistoricCaseInstanceQuery involvedUser(String userId) {\n        if (userId == null) {\n            throw new FlowableIllegalArgumentException(\"involvedUser is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.involvedUser = userId;\n        } else {\n            this.involvedUser = userId;\n        }\n        return this;\n    }\n    \n    @Override\n    public HistoricCaseInstanceQuery involvedUser(String userId, String identityLinkType) {\n        if (userId == null) {\n            throw new FlowableIllegalArgumentException(\"userId is null\");\n        }\n        if (identityLinkType == null) {\n            throw new FlowableIllegalArgumentException(\"identityLinkType is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.involvedUserIdentityLink = new IdentityLinkQueryObject(userId, null, identityLinkType);\n        } else {\n            this.involvedUserIdentityLink = new IdentityLinkQueryObject(userId, null, identityLinkType);\n        }\n        return this;\n    }\n    \n    @Override\n    public HistoricCaseInstanceQuery involvedGroup(String groupId, String identityLinkType) {\n        if (groupId == null) {\n            throw new FlowableIllegalArgumentException(\"groupId is null\");\n        }\n        if (identityLinkType == null) {","sourceCodeStart":1077,"sourceCodeEnd":1113,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java#L1077-L1113","documentation":"HistoricCaseInstanceQueryImpl.involvedUser(String userId, String identityLinkType) throws FlowableIllegalArgumentException(\"userId is null\") when the userId parameter is null. This overload filters involvement by a specific identity link type (e.g. participant, owner), and both parameters are required.","triggerScenarios":"Calling involvedUser(null, identityLinkType) on a HistoricCaseInstanceQuery; typical when the identity-link-typed variant is chosen but the user id source is null.","commonSituations":"Refactoring from the single-arg involvedUser to the two-arg version while the user id can still be null; user id comes from a header/claim that is absent; test data omitted the user id.","solutions":["Ensure userId is non-null before calling the two-arg involvedUser.","If the link type matters but the user is optional, guard the call with a null check.","Note the same method also throws \"identityLinkType is null\" — validate both parameters.","Provide sensible defaults (e.g. skip the filter) for anonymous/no-user scenarios."],"exampleFix":"// before\nquery.involvedUser(userId, IdentityLinkType.PARTICIPANT); // userId may be null\n// after\nif (userId != null) {\n    query.involvedUser(userId, IdentityLinkType.PARTICIPANT);\n}","handlingStrategy":"validation","validationCode":"if (userId == null) {\n    throw new IllegalArgumentException(\"userId is required\");\n}\nif (identityLinkType == null) {\n    throw new IllegalArgumentException(\"identityLinkType is required\");\n}\nquery.involvedUser(userId, identityLinkType);","typeGuard":"boolean canFilterByUserLink(String userId, String type) {\n    return userId != null && type != null;\n}","tryCatchPattern":"try {\n    query.involvedUser(userId, identityLinkType);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"is null\")) {\n        // skip filter or rethrow with context\n    } else {\n        throw e;\n    }\n}","preventionTips":["Validate both userId and identityLinkType together before the two-arg call","Use constants from IdentityLinkType rather than raw strings","Guard user-derived values from headers/claims which are commonly absent","Prefer the single-arg involvedUser when link type is irrelevant"],"tags":["java","flowable","cmmn","query","null-argument","identity-link"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}