{"record":{"id":"61ef7e184c6e370a","repo":"pinpoint-apm/pinpoint","slug":"there-is-not-userid-or-fail-to-create-usergroup","errorCode":null,"errorMessage":"There is not userId or fail to create userGroup.","messagePattern":"There is not userId or fail to create userGroup\\.","errorType":"exception","errorClass":"PinpointUserGroupException","httpStatus":null,"severity":"error","filePath":"user/src/main/java/com/navercorp/pinpoint/user/service/UserGroupServiceImpl.java","lineNumber":97,"sourceCode":"        this.userConfigProperties = Objects.requireNonNull(userConfigProperties, \"userConfigProperties\");\n        this.userService = Objects.requireNonNull(userService, \"userService\");\n        this.userGroupDeletionListeners = List.copyOf(\n                Objects.requireNonNull(userGroupDeletionListeners, \"userGroupDeletionListeners\")\n        );\n    }\n\n    @Override\n    public String createUserGroup(UserGroup userGroup) throws PinpointUserGroupException {\n        if (userGroupDao.isExistUserGroup(userGroup.getId())) {\n            throw new PinpointUserGroupException(\"userGroup's name already exist. :\" + userGroup.getId());\n        }\n\n        String userGroupNumber = userGroupDao.createUserGroup(userGroup);\n\n        if (!userConfigProperties.isOpenSource()) {\n            String userId = userService.getUserIdFromSecurity();\n            if (StringUtils.isEmpty(userId)) {\n                throw new PinpointUserGroupException(\"There is not userId or fail to create userGroup.\");\n            }\n\n            insertMember(new UserGroupMember(userGroup.getId(), userId));\n        }\n\n        return userGroupNumber;\n    }\n\n    @Override\n    @Transactional(readOnly = true)\n    public List<UserGroup> selectUserGroup() {\n        return userGroupDao.selectUserGroup();\n    }\n\n    @Override\n    @Transactional(readOnly = true)\n    public List<UserGroup> selectUserGroupByUserId(String userId) {\n        return userGroupDao.selectUserGroupByUserId(userId);","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/user/src/main/java/com/navercorp/pinpoint/user/service/UserGroupServiceImpl.java#L79-L115","documentation":"When not running in open-source mode, createUserGroup fetches the current authenticated user's id via userService.getUserIdFromSecurity() to auto-insert the creator as a group member; if the id is empty/blank it throws PinpointUserGroupException because the group would be created without an owner. Note: by then the group row may already be inserted.","triggerScenarios":"Calling createUserGroup with isOpenSource=false while the security context holds no user id — e.g. unauthenticated/internal calls, scheduler-triggered creation, or a security setup where getUserIdFromSecurity returns empty.","commonSituations":"Non-open-source (enterprise) builds where calls bypass Spring Security authentication; batch/CLI provisioning of user groups without a logged-in user.","solutions":["Ensure the request is authenticated so getUserIdFromSecurity returns a valid id.","Pass through the authenticated web endpoint rather than calling the service internally without a security context.","Catch PinpointUserGroupException and clean up / retry with an explicit creator id."],"exampleFix":"// before\nuserGroupService.createUserGroup(group); // from unauthenticated batch\n// after\nUserGroupMember member = new UserGroupMember(group.getId(), authenticatedUserId);\nuserGroupService.createUserGroup(group);\nuserGroupService.insertMember(member);","handlingStrategy":"try-catch","validationCode":"String userId = userService.getUserIdFromSecurity();\nif (StringUtils.isEmpty(userId)) { /* abort or supply explicit creator */ }","typeGuard":null,"tryCatchPattern":"try { userGroupService.createUserGroup(group); } catch (PinpointUserGroupException e) { /* no authenticated user — retry authenticated or clean up */ }","preventionTips":["Only call from authenticated request threads","In non-open-source mode never invoke the service from unauthenticated jobs","Provide explicit creator id when bypassing the web layer"],"tags":["user-group","security-context","authentication"],"backgroundTag":"authentication-required","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}