Amplify-js: verifyUserAttribute does not appear to send clientMetadata

Created on 21 Apr 2020  路  6Comments  路  Source: aws-amplify/amplify-js

Describe the bug
While implementing MFA I'm attempting to add a phone number attribute to the user. UpdateUser works fine (though it doesn't trigger the CustomMessage_UpdateUserAttribute lambda, but that's not an amplify issue).
When I call Auth.verifyUserAttribute(user, 'phone_number', { product: 'myProductName' } the cloudwatch logs show no clientMetadata property in the event.

Error from my backend code:

{code: "UserLambdaValidationException", name: "UserLambdaValidationException", message: "CustomMessage failed with error Unsupport product undefined."}

To Reproduce
Steps to reproduce the behavior:

  1. Create a pool with a user that has an unverified phone number, and a CustomMessage trigger
  2. Use the Amplify package to call verifyUserAttribute for that user and pass the third parameter some object;
  3. Check the logs of the CustomMessage trigger and see something like
    "triggerSource": "CustomMessage_VerifyUserAttribute",
    "request": {
        "userAttributes": {
            "sub": "<sub>",
            "email_verified": "true",
            "cognito:user_status": "CONFIRMED",
            "cognito:email_alias": "<email>",
            "phone_number_verified": "false",
            "phone_number": "<phone>",
            "given_name": "Michael",
            "family_name": "Riffle",
            "email": "<email>"
        },
        "codeParameter": "{####}",
        "linkParameter": "{##Click Here##}",
        "usernameParameter": null
    },

Expected behavior
The request property should have a clientMetadata property that was passed into the function.

Code Snippet
Please provide a code snippet or a link to sample code of the issue you are experiencing to help us reproduce the issue. (Be sure to remove any sensitive data)

  async verifyUserAttribute() {
    try {
      const user = await Auth.currentAuthenticatedUser();
      if (!user) {
        throw new Error('User must be initialized to verify attributes');
      }

      const res = await Auth.verifyUserAttribute(user, 'phone_number', {
        product: process.env.REACT_APP_PRODUCT,
      });
    } catch (err) {
      throw err;
    }
  }

Additional context
We're using lambda triggers from cognito for a bunch of other use-cases and everything is working fine. Our app supports
CustomMessage_SignUp
CustomMessage_ResendCode
CustomMessage_ForgotPassword
PostConfirmation_ConfirmSignUp
PostAuthentication_Authentication
And they all work great.
This _might_ be an issue lower down with Cognito itself? But I wanted to check here first.

Auth pending-close-response-required to-be-reproduced

Most helpful comment

Hi @rifflock - thanks for filling this. I was able to reproduce this error on my end. Let me check-in with the team on how to move forward.

All 6 comments

Hi @rifflock - thanks for filling this. I was able to reproduce this error on my end. Let me check-in with the team on how to move forward.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Hey @mauerbac (or @ashika01)! Did the team get back to you on this? Thanks!

Hi @rifflock - thanks for filling this. I was able to reproduce this error on my end. Let me check-in with the team on how to move forward.

Is there any update on this? We too are blocked by clientMetadata not being available in the event. It's really causing us issues, while other triggers are working perfectly.

Any news on this ?

We just merged a PR to address this issue. It is available available now on aws-amplify@unstable and will be on latest when we do our next release (likely later this week).

Was this page helpful?
0 / 5 - 0 ratings