MrHertal / react-admin-amplify

AWS Amplify data provider for react-admin.
MIT License
159 stars 42 forks source link

Calling AdminQueries listUsers on resource cognitoUsers cause 500 errors from Amplify #88

Closed ahmadsholehin closed 1 year ago

ahmadsholehin commented 1 year ago
<Resource
  name="cognitoUsers"
  list={ CognitoUserList }
  show={ CognitoUserShow }
/>

Does not work anymore via react-admin-amplify. Calls to amplify listUsers?limit=10&token= result in getting 500 errors with error message {"message":"STRING_VALUE can not be converted to an Integer"}.

Wondering if anyone having the same issue? Or am I doing something wrong here? Using AMAZON_COGNITO_USER_POOLS and AdminQueries already set up in Amplify. Other resources works fine.

ahmadsholehin commented 1 year ago

Adding to the above, interestingly, I observed that if the limit parameter is capitalised, i.e. listUsers?Limit=10&token=, Amplify responds perfectly fine.

Not sure about the token parameter though. Peeking into generated AdminQueries source, it seems listUser and listGroups accepts Limit and PaginationToken parameters, whilst listGroupsForUser and listUsersInGroup accepts Limit and NextToken parameters. Not sure if this is a breaking change in Amplify CodeGen that causes this issue.

ahmadsholehin commented 1 year ago

Out of desperation, I decided to throw out cognitoActions.js generated by Amplify and use the file in the react-admin-amplify-demo repo: https://github.com/MrHertal/react-admin-amplify-demo/blob/2df55b5579188100f80acae95ea84eb56d437a9e/amplify/backend/function/AdminQueries6ffead5e/src/cognitoActions.js

Remember to change package.json to use the older aws-sdk.

Now Amplify stops complaining about SerializationException issues and returns users correctly.