Error visualizing a Cognito user whose username has a percent (%) character

0

When using the Amazon Cognito service through the AWS Management Console, I can see all users registered in a User Pool. When I click a user with a "nice" username, I can see all of the user's information, attributes, group memberships, etc. However, when I click a user with a username containing the "%" character (e.g. "john%doe"), I am redirected to a completely blank page. Upon looking at the JavaScript console for that blank page, I see the error "URIError: URI malformed". I believe the error is caused by the "%" character in the username, since in this case the URI I am redirected to has the form https://REGION.console.aws.amazon.com/cognito/.../details/not%nice%username?region=REGION. It seems the code has problems parsing a URI where the username has the "%" character. I need to access user details so that I can change the group the user belongs to. Any idea how I can accomplish this without running into this error?

1 Answer
1
Accepted Answer

You are correct, the "%" character is not allowed in usernames in Amazon Cognito. This is because the "%" character is a special character that is used in URIs to encode certain characters. When the Cognito console tries to parse the URI for the user details page, it encounters the "%" character and fails.

I recommend using the AWS CLI or SDK to access the user details. This is the simplest and most reliable way to get the job done.

Here is an example of how you can use the AWS CLI to get the user details:

aws cognito-idp get-user --user-pool-id <user-pool-id> --username <username>

Replace <user-pool-id> with the ID of your user pool and <username> with the username of the user.

The output of this command will contain all of the user's information, including their group memberships.

profile pictureAWS
answered 8 months ago
  • Thank you for your answer, I will try using the CLI. However, if % causes problems in the Cognito management console, I believe the character should either be disallowed in usernames (which it isn't, since I am able to create users with this character) or the site should build the URI differently for usernames with "%", such as by escaping it with the "%25" escape code.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions