- Más nuevo
- Más votos
- Más comentarios
The error message you're receiving, "INVALID_PARAMETER 1 validation error detected: Value at 'username' failed to satisfy constraint: Member must satisfy regular expression pattern: [\p{L}\p{M}\p{S}\p{N}\p{P}]+", is indicating that the username you're trying to update does not match the required pattern.
The regular expression [\p{L}\p{M}\p{S}\p{N}\p{P}]+
is a Unicode-aware pattern that matches one or more characters of the following types:
\p{L}
: Any letter character from any language\p{M}
: Any spacing or combining mark character\p{S}
: Any symbol character\p{N}
: Any numeric character\p{P}
: Any punctuation character
The issue you're facing is likely due to the presence of the parentheses ()
in the username. The parentheses are not considered valid characters in the regular expression pattern.
To resolve this issue, you can try the following:
-
Modify the username format: Consider modifying the format of the username to remove the parentheses, such as "Bill_Admin" instead of "Bill (Admin)". This should allow the
AdminUpdateUserAttributes
operation to succeed. -
Use a different attribute: Instead of updating the username, you can try updating a different user attribute, such as the
preferred_username
attribute, which may have a different validation pattern. -
Perform a workaround: As a workaround, you could first use the
AdminGetUser
operation to retrieve the current user attributes, then useAdminUpdateUserAttributes
to update the desired attributes, excluding the username.
Here's an example of how you could perform the workaround:
// Retrieve the current user attributes GetUserResponse getUserResponse = cognitoIdentityProvider.AdminGetUser(GetUserRequest() .WithUsername(username) .WithUserPoolId(userPoolId)); // Update the desired attributes, excluding the username UpdateUserAttributesRequest updateRequest; updateRequest.SetUserAttributes(getUserResponse.GetUser().GetAttributes()); // Modify the desired attributes here updateRequest.SetUserPoolId(userPoolId); updateRequest.SetUsername(username); // Update the user attributes UpdateUserAttributesOutcome updateOutcome = cognitoIdentityProvider.AdminUpdateUserAttributes(updateRequest);
If none of these approaches work, you may need to consider contacting AWS Support to investigate further or provide feedback on the SDK behavior.
Contenido relevante
- OFICIAL DE AWSActualizada hace un año
- OFICIAL DE AWSActualizada hace 3 años
- OFICIAL DE AWSActualizada hace un año
- OFICIAL DE AWSActualizada hace un año
Hello JonQ, Thanks for your detailed answer. This is actually in some test code I'm writing, so fortunately I don't need to update any existing users, but I would rather not have to exclude parentheses when a new user enters their name unless I have to; it seems an unnecessary limitation for my users. I'm not sure the parentheses themselves are the problem, anyway - I would have thought they were covered by \p{S} or \p{P}. And if I exclude the space (i.e. use "Name(Details)" , then Cognito doesn't have a problem with the name. Looks like I'm going to have to report this as a possible bug... Thanks Liam