{"record":{"id":"5dd084e5155eb239","repo":"flowable/flowable-engine","slug":"userid-is-null-5dd084","errorCode":null,"errorMessage":"userId is null","messagePattern":"userId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/GetUserPictureCmd.java","lineNumber":41,"sourceCode":"import org.flowable.idm.api.User;\nimport org.flowable.idm.engine.impl.util.CommandContextUtil;\n\n/**\n * @author Tom Baeyens\n */\npublic class GetUserPictureCmd implements Command<Picture>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String userId;\n\n    public GetUserPictureCmd(String userId) {\n        this.userId = userId;\n    }\n\n    @Override\n    public Picture execute(CommandContext commandContext) {\n        if (userId == null) {\n            throw new FlowableIllegalArgumentException(\"userId is null\");\n        }\n\n        User user = CommandContextUtil.getIdmEngineConfiguration().getIdmIdentityService()\n                .createUserQuery().userId(userId)\n                .singleResult();\n\n        if (user == null) {\n            throw new FlowableObjectNotFoundException(\"user \" + userId + \" doesn't exist\", User.class);\n        }\n\n        return CommandContextUtil.getUserEntityManager(commandContext).getUserPicture(user);\n    }\n\n}\n","sourceCodeStart":23,"sourceCodeEnd":56,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/GetUserPictureCmd.java#L23-L56","documentation":"GetUserPictureCmd fetches a user's Picture by userId. Because a null userId cannot match any user row, the command rejects it up front with FlowableIllegalArgumentException before issuing the identity query.","triggerScenarios":"Calling identityService.getUserPicture(null) or executing new GetUserPictureCmd(null) when the Picture was never set or the userId variable was never populated.","commonSituations":"Code that reads a userId from a task/process variable, authentication context, or request parameter that is absent at runtime; calling getUserPicture before creating the user.","solutions":["Pass a non-null userId; verify the variable or parameter actually holds the id","Skip the call when userId is null instead of delegating to the engine","Handle FlowableIllegalArgumentException where null userIds are expected"],"exampleFix":"// before\nPicture picture = identityService.getUserPicture(userId);\n// after\nPicture picture = userId != null ? identityService.getUserPicture(userId) : null;","handlingStrategy":"validation","validationCode":"if (userId == null || userId.isEmpty()) throw new IllegalArgumentException(\"userId is required\");","typeGuard":"boolean hasUserId(String userId) { return userId != null && !userId.trim().isEmpty(); }","tryCatchPattern":"try { Picture p = identityService.getUserPicture(userId); } catch (FlowableIllegalArgumentException e) { log.warn(\"userId missing, no picture\"); }","preventionTips":["Null-check variables read from process/task context before service calls","Use Optional<String> for userIds flowing through your service layer","Only call getUserPicture for users known to exist"],"tags":["flowable","idm","null-argument","user"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}