-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Getting 500 error response for client errors in SCIM/Groups PATCH #478
Changes from 3 commits
79f4362
fedd887
6dcdab9
ed20895
bea2a6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ | |
import org.wso2.carbon.user.core.claim.ClaimManager; | ||
import org.wso2.carbon.user.core.common.AbstractUserStoreManager; | ||
import org.wso2.carbon.user.core.constants.UserCoreClaimConstants; | ||
import org.wso2.carbon.user.core.constants.UserCoreErrorConstants; | ||
import org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager; | ||
import org.wso2.carbon.user.core.model.Condition; | ||
import org.wso2.carbon.user.core.model.ExpressionAttribute; | ||
|
@@ -3366,9 +3367,14 @@ private void doPatchGroup(String groupId, String currentGroupName, Map<String, L | |
temporaryMembers.clear(); | ||
|
||
for (String member : deletedMembers) { | ||
String username = UserCoreUtil.addDomainToName(UserCoreUtil.removeDomainFromName(member), | ||
userStoreDomainForGroup); | ||
temporaryMembers.add(username); | ||
if (addedMembers.isEmpty() && StringUtils.isBlank(member)) { | ||
throw new BadRequestException(ResponseCodeConstants.INVALID_VALUE); | ||
} | ||
if (StringUtils.isNotBlank(member)) { | ||
String username = UserCoreUtil.addDomainToName(UserCoreUtil.removeDomainFromName(member), | ||
userStoreDomainForGroup); | ||
temporaryMembers.add(username); | ||
} | ||
} | ||
|
||
deletedMembers.clear(); | ||
|
@@ -3413,13 +3419,16 @@ private void doPatchGroup(String groupId, String currentGroupName, Map<String, L | |
carbonUM.updateGroupName(currentGroupName, newGroupName); | ||
|
||
} catch (UserStoreException e) { | ||
if (e instanceof org.wso2.carbon.user.core.UserStoreException && StringUtils | ||
.equals(UserCoreErrorConstants.ErrorMessages.ERROR_CODE_NON_EXISTING_USER.getCode(), | ||
((org.wso2.carbon.user.core.UserStoreException) e).getErrorCode())) { | ||
throw new BadRequestException(ResponseCodeConstants.INVALID_VALUE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why aren't we passing the throwable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is the implementation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a log with the throwable as suggested offline. |
||
} | ||
throw resolveError(e, e.getMessage()); | ||
} catch (IdentitySCIMException e) { | ||
throw new CharonException(e.getMessage(), e); | ||
} catch (IdentityApplicationManagementException e) { | ||
throw new CharonException("Error retrieving User Store name. ", e); | ||
} catch (BadRequestException e) { | ||
throw new CharonException("Error in updating the group", e); | ||
} | ||
} | ||
|
||
|
@@ -3462,10 +3471,6 @@ private void prepareAddedRemovedMemberLists(Set<String> addedMembers, Set<String | |
SCIMConstants.OperationalConstants.REMOVE)) { | ||
addedMembers.remove(memberObject.get(SCIMConstants.GroupSchemaConstants.DISPLAY)); | ||
removedMembers.add(memberObject.get(SCIMConstants.GroupSchemaConstants.DISPLAY)); | ||
String value = memberObject.get(SCIMConstants.GroupSchemaConstants.VALUE); | ||
if (StringUtils.isNotBlank(value)) { | ||
deletedMemberIds.add(value); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -3660,7 +3665,7 @@ private Set<String> getMemberValuesFromUserstore(Set<String> memberUsernames, St | |
if (StringUtils.isEmpty(userId)) { | ||
String error = "User: " + userName + " doesn't exist in the user store. Hence can not update the " + | ||
"group: " + displayName; | ||
throw new BadRequestException(error); | ||
throw new BadRequestException(error, ResponseCodeConstants.INVALID_VALUE); | ||
} | ||
memberUserIds.add(userId); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason for removing java version 17?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed this https://github.com/wso2-extensions/identity-inbound-auth-oauth/blob/6cb4c30737e62537aad1d94c07e88283dcf80198/.github/workflows/pr-builder.yml#L23 as a workaround for the build failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include jdk-17.0.7+7 as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in bea2a6a