{"record":{"id":"96b857c6edd65b42","repo":"flowable/flowable-engine","slug":"group-is-null","errorCode":null,"errorMessage":"group is null","messagePattern":"group is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/SaveGroupCmd.java","lineNumber":45,"sourceCode":" * @author Joram Barrez\n */\npublic class SaveGroupCmd implements Command<Void>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    \n    protected IdmEngineConfiguration idmEngineConfiguration;\n    \n    protected Group group;\n\n    public SaveGroupCmd(Group group, IdmEngineConfiguration idmEngineConfiguration) {\n        this.group = group;\n        this.idmEngineConfiguration = idmEngineConfiguration;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (group == null) {\n            throw new FlowableIllegalArgumentException(\"group is null\");\n        }\n\n        if (idmEngineConfiguration.getGroupEntityManager().isNewGroup(group)) {\n            if (group instanceof GroupEntity) {\n                idmEngineConfiguration.getGroupEntityManager().insert((GroupEntity) group);\n            } else {\n                CommandContextUtil.getDbSqlSession(commandContext).insert((Entity) group, idmEngineConfiguration.getIdGenerator());\n            }\n        } else {\n            if (group instanceof GroupEntity) {\n                idmEngineConfiguration.getGroupEntityManager().update((GroupEntity) group);\n            } else {\n                CommandContextUtil.getDbSqlSession(commandContext).update((Entity) group);\n            }\n\n        }\n        return null;\n    }","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/SaveGroupCmd.java#L27-L63","documentation":"SaveGroupCmd persists a Group via the GroupEntityManager (insert for new groups, update for existing ones). A null Group object has no id or state to persist, so the command throws FlowableIllegalArgumentException before touching the entity manager.","triggerScenarios":"Calling identityService.saveGroup(null) or executing new SaveGroupCmd(config, null); also when a Group variable is expected from an earlier lookup that returned null.","commonSituations":"Chaining code like saveGroup(findGroup(name)) where the lookup failed; deserializing groups from JSON/config where the field is missing; Spring injection of a group bean that failed.","solutions":["Ensure the Group instance is created (identityService.newGroup(id)) before saving","Check the preceding lookup/call that produced the null group reference","Guard the save call with a null check to skip or create the group as needed"],"exampleFix":"// before\nidentityService.saveGroup(group);\n// after\nif (group == null) {\n    group = identityService.newGroup(groupId);\n}\nidentityService.saveGroup(group);","handlingStrategy":"validation","validationCode":"if (group == null) throw new IllegalArgumentException(\"group must not be null\");","typeGuard":"boolean isSavableGroup(Group g) { return g != null && g.getId() != null && !g.getId().trim().isEmpty(); }","tryCatchPattern":"try { identityService.saveGroup(group); } catch (FlowableIllegalArgumentException e) { log.error(\"Attempted to save null group\", e); }","preventionTips":["Create groups with identityService.newGroup(id) before saving","Check results of group lookups before passing them onward","Validate deserialized group objects before persistence"],"tags":["flowable","idm","null-argument","group"],"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"}