- Newest
- Most votes
- Most comments
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:
-
Handle both InvalidParameterException and ResourceNotFoundException in your code as potential indicators that the user doesn't exist.
-
Before attempting to delete a user, you could first verify if the user exists using another API call (such as ListUsers if available).
-
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

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.