aws / aws-aspnet-cognito-identity-provider

ASP.NET Core Identity Provider for Amazon Cognito
https://aws.amazon.com/developer/language/net/
Apache License 2.0
215 stars 89 forks source link

We can no longer search or find users with this sdk #235

Closed meanstream closed 11 months ago

meanstream commented 11 months ago

Describe the bug

We can no longer search or find users with this sdk and it's in production. Here's the error we recieved from the cognito api / sdk:

Amazon.AspNetCore.Identity.Cognito.Exceptions.CognitoServiceException: Failed to retrieve the list of users from Cognito. ---> Amazon.CognitoIdentityProvider.Model.InvalidParameterException: Error while parsing filter. ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown. at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\HttpHandler_mobile\HttpRequestMessageFactory.cs:line 539 at Amazon.Runtime.Internal.HttpHandler1.InvokeAsync[T](IExecutionContext executionContext) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\HttpHandler\HttpHandler.cs:line 175 at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext) --- End of inner exception stack trace --- at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext executionContext, HttpErrorResponseException exception) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\HttpErrorResponseExceptionHandler.cs:line 60 at Amazon.Runtime.Internal.ErrorHandler.ProcessException(IExecutionContext executionContext, Exception exception) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\ErrorHandler.cs:line 212 at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\ErrorHandler.cs:line 104 at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\EndpointDiscoveryHandler.cs:line 79 at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\CredentialsRetriever.cs:line 98 at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\RetryHandler\RetryHandler.cs:line 137 at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.AspNetCore.Identity.Cognito.CognitoUserStore1.GetUsersAsync(CognitoAttribute attributeFilterName, CognitoAttributeFilterType attributeFilterType, String attributeFilterValue, CancellationToken cancellationToken) --- End of inner exception stack trace --- at Amazon.AspNetCore.Identity.Cognito.CognitoUserStore1.GetUsersAsync(CognitoAttribute attributeFilterName, CognitoAttributeFilterType attributeFilterType, String attributeFilterValue, CancellationToken cancellationToken) at Plunk.Identity.Model.UserManagerExtensions.FindAsync(CognitoUserManager1 manager, Expression`1 predicate) at Plunk.Service.Account.UserService.SearchUsersAsync(String term)

Expected Behavior

List of users should be returned or at least not return an error.

Current Behavior

Amazon.AspNetCore.Identity.Cognito.Exceptions.CognitoServiceException: Failed to retrieve the list of users from Cognito.

Reproduction Steps

The issue is with the CognitoUserManager: https://github.com/aws/aws-aspnet-cognito-identity-provider/blob/master/src/Amazon.AspNetCore.Identity.Cognito/CognitoUserManager.cs

Calling the below methods based in the sdk above causes the error. This aws sdk has worked for years with no updates by the AWS team and now fails.

await _userManager.GetUsersAsync()

or

await _userManager.FindAsync(x =>x.Attributes.ContainsKey(CognitoAttributesConstants.Email) && x.Attributes[CognitoAttributesConstants.Email].StartsWith(term, StringComparison.Ordinal));

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.AspNetCore.Identity.Cognito - 1.0.5

Targeted .NET Platform

.Net Core 3.1, .NET 6

Operating System and version

OSX, Ubuntu

ashishdhingra commented 11 months ago

@meanstream Good afternoon. The issue is reproducible even using the latest version of Amazon.AspNetCore.Identity.Cognito. Looks like Cognito service is returning error Error while parsing filter. while executing await _userManager.GetUsersAsync().

We are aware of the issue and working with service team to resolve it. I will update here once the issue is rectified.

Thanks, Ashish

ashishdhingra commented 11 months ago

@meanstream This appears to be fixed by the service team based on my testing. Resolving the issue.

github-actions[bot] commented 11 months ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.