Skip to content

Amazon Rekognition - Unexpected Error from DeleteUsersAsync method call

0

Hello, I am trying to utilize the DeleteUser in C# AWSSSO.Rekognition. When I pass in the CollectionId and UserId of a valid User, I am able to Delete the User without issue. When I pass in a valid CollectionId, but a UserId of a User that does not exist, I get an InvalidParameterException instead of the expected ResourceNotFoundException.

For both the Users that exist, and the User that does not, I am utilizing a string GUID, which falls within allowed Input Param pattern. I am looking for a way to differentiate whether the User does not exist, but am getting this error every time instead.

The documentation above lists both InvalidParameterException and ResourceNotFoundException as valid exceptions returned by the method.

asked 5 months ago41 views
1 Answer
1

When using the DeleteUser operation in Amazon Rekognition, you're encountering an InvalidParameterException when attempting to delete a user that doesn't exist, rather than the ResourceNotFoundException you expected.

This behavior appears to be inconsistent with what you might expect based on the API documentation. The InvalidParameterException indicates that an input parameter violated a constraint, which suggests that the system is treating the non-existent UserId as an invalid parameter rather than a missing resource.

To work around this issue, you could:

  1. Handle both InvalidParameterException and ResourceNotFoundException in your code as potential indicators that the user doesn't exist.

  2. Before attempting to delete a user, you could first verify if the user exists using another API call (such as ListUsers if available).

  3. Implement error handling that treats the InvalidParameterException in this specific context as an indication that the user doesn't exist.

If you need to specifically differentiate between a user that doesn't exist and other parameter validation issues, you may want to examine the error message details within the InvalidParameterException to see if it provides more specific information about why the parameter was considered invalid.
Sources
Deleting a user - Amazon Rekognition
DeleteUser - Amazon Rekognition

answered 5 months ago
EXPERT
reviewed 5 months ago
  • I am looking to avoid making extra calls like ListUsers just to check if the resource exists before deleting, due to rate limiting. I will follow what this post suggests of treating the InvalidParameterException as ResourceNotFoundException, but I would first like to confirm that this is expected, since this would be purposefully introducing code smell.

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.

Relevant content