{"record":{"id":"bfebb486935ccf32","repo":"flowable/flowable-engine","slug":"userid-is-null-bfebb4","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/SetUserPictureCmd.java","lineNumber":43,"sourceCode":"\n/**\n * @author Tom Baeyens\n */\npublic class SetUserPictureCmd implements Command<Object>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String userId;\n    protected Picture picture;\n\n    public SetUserPictureCmd(String userId, Picture picture) {\n        this.userId = userId;\n        this.picture = picture;\n    }\n\n    @Override\n    public Object 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        CommandContextUtil.getUserEntityManager(commandContext).setUserPicture(user, picture);\n        return null;\n    }\n\n}\n","sourceCodeStart":25,"sourceCodeEnd":59,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/SetUserPictureCmd.java#L25-L59","documentation":"SetUserPictureCmd stores a Picture for a user identified by userId. The userId is the lookup key for the target user, so a null value is rejected up front with FlowableIllegalArgumentException before querying the identity service.","triggerScenarios":"Calling identityService.setUserPicture(null, picture) or executing new SetUserPictureCmd(null, picture); also reached from executeActivityBehavior when the userId process variable is unset.","commonSituations":"Delegates/behavior classes reading a userId variable that was never set on the execution; image-upload endpoints that drop the user id parameter.","solutions":["Set the userId variable/parameter before invoking the behavior or service call","Guard the call: only setUserPicture when userId != null","Ensure the calling ActivityBehavior initializes its fields in the setter/constructor"],"exampleFix":"// before\nidentityService.setUserPicture(userId, picture);\n// after\nif (userId != null) {\n    identityService.setUserPicture(userId, picture);\n}","handlingStrategy":"validation","validationCode":"if (userId == null || userId.isEmpty()) throw new IllegalArgumentException(\"userId is required to set a picture\");","typeGuard":"boolean canSetPicture(String userId, Picture p) { return userId != null && !userId.trim().isEmpty() && p != null; }","tryCatchPattern":"try { identityService.setUserPicture(userId, picture); } catch (FlowableIllegalArgumentException e) { log.warn(\"Cannot set picture: missing userId\"); }","preventionTips":["Ensure ActivityBehavior userId fields are set before execute runs","Set the userId process variable before delegating to picture logic","Null-check variables pulled from execution context"],"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"}