Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException Attempt to invoke virtual method 'java.lang.String com.amazonaws.services.cognitoidentityprovider.model.CodeDeliveryDetailsType.getDestination()' on a null object reference #1264

Closed
SubirZ opened this issue Oct 21, 2019 · 13 comments
Labels
bug Something isn't working mobile client Issues with AWS Mobile's client-side Cognito wrapper

Comments

@SubirZ
Copy link

SubirZ commented Oct 21, 2019

Getting the following issue on SignUp result using the AWSMobileClient.
It always goes into onError() even after providing a valid username, email, password.
In AWS console the user is getting created and validated as well.

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.amazonaws.services.cognitoidentityprovider.model.CodeDeliveryDetailsType.getDestination()' on a null object reference

To Reproduce
A code sample or steps:

fun signUpUser(userName: String, userEmail: String, password: String) {
        val attributes = HashMap<String, String>()
        attributes.put(AppConstants.ATTRIBUTE_NAME, userName)
        attributes.put(AppConstants.ATTRIBUTE_EMAIL, userEmail)
        AWSMobileClient.getInstance().signUp(userEmail, password, attributes, null, object :
            Callback<com.amazonaws.mobile.client.results.SignUpResult> {
            override fun onResult(signUpResult: com.amazonaws.mobile.client.results.SignUpResult?) {
                //signUp was Successful
                Log.d("TAG", "Sign up Success...isConfirmed" + signUpResult?.confirmationState)

                signUpResult?.let {
                    if (!it.confirmationState) {
                        Log.d(
                            "TAG", "Sign up Success...not Confirmed. verification code sent to:"
                                    + signUpResult.userCodeDeliveryDetails.destination
                        )
                        authResponseLiveData.postValue(SignUpResultStatus.VERIFICATION_REQUIRED)
                    } else {
                        Log.d("TAG", "Sign up Success...user Confirmed")
                        authResponseLiveData.postValue(SignUpResultStatus.SIGNED_UP_SUCCESSFULLY)
                    }
                }
            }

            override fun onError(exception: Exception?) {
                val errorMessage: String = if (exception is AmazonServiceException) {
                    Log.d("SignUp Failure", exception.errorMessage)
                    exception.errorMessage
                } else {
                    Log.d("SignUp Failure", "Something went wrong.")
                    "Something went wrong."
                }
                errorLiveData.postValue(Event(errorMessage))
            }
        })
}

Which AWS service(s) are affected?
AWSMobileClient SignUp()

Expected behavior
SignUp Result as success or failure

Environment Information (please complete the following information):

  • AWS Android SDK Version: [e.g. 2.16.1]
    com.amazonaws:aws-android-sdk-mobile-client:2.16.1
  • Device: [e.g. Pixel XL, Simulator]
  • Android Version: [e.g. Nougat 7.1.2]
@mutablealligator mutablealligator added mobile client Issues with AWS Mobile's client-side Cognito wrapper bug Something isn't working labels Oct 21, 2019
@mutablealligator
Copy link
Contributor

@SubirZ Thank you for reporting to us. Sorry for the inconvenience caused.

Does this happen for every signUp operation?
Have you configured MFA in Cognito UserPools?
Can you describe the SignUp flow you have configured with Amazon Cognito?

@SubirZ
Copy link
Author

SubirZ commented Oct 22, 2019

@kvasukib Thanks for the reply. No, we haven't configured our user pool to have MFA or Verification enabled in our settings. The signup flow is as follows,

We have set email and name as required attributes for the user pool.
We are calling the signup method on AwsMobile client with required parameters (username, password) along with attributes.

When we are doing that, the user is successfully being created in the user pool. But the issue is, we aren't getting a successful response. It will trigger onError callback.

For more insight, this is exactly how our issue is https://forums.aws.amazon.com/thread.jspa?messageID=720943

Not to mention, when we use the same above described flow from IOS and WEB, we get a successful response. Any help on this would be appreciated. Thanks

@mutablealligator
Copy link
Contributor

@SubirZ Thank you for sharing the history of the old issue and the details. The issue has been addressed in the Cognito UserPools SDK (aws-android-sdk-cognitoidentityprovider), however the issue still exists in AWSMobileClient SDK (aws-android-sdk-mobile-client). I am working on a fix for the problem and in the process of testing it. I will update this issue with more details when the bug fix is released. Thank you!

@mutablealligator mutablealligator added pending-release Code has been merged but pending release and removed Investigating labels Oct 24, 2019
@SubirZ
Copy link
Author

SubirZ commented Oct 24, 2019

@kvasukib Thanks for the prompt reply, eagerly looking forward to the resolution of the issue. Thank you!

@mutablealligator
Copy link
Contributor

PR #1272 will address this issue.

@trivedishivang
Copy link

trivedishivang commented Oct 31, 2019

@kvasukib Is the release date planned for #1272 planned?

@mutablealligator
Copy link
Contributor

The fix has been released in 2.16.3 release. Please upgrade and let us know if the fix works.

@mutablealligator mutablealligator added closing soon Issue will auto-close if there is no additional activity within 7 days. and removed pending-release Code has been merged but pending release labels Nov 6, 2019
@stale stale bot removed the closing soon Issue will auto-close if there is no additional activity within 7 days. label Nov 6, 2019
@mutablealligator mutablealligator added the closing soon Issue will auto-close if there is no additional activity within 7 days. label Nov 6, 2019
@trivedishivang
Copy link

Thanks! Will test it and update.

@stale stale bot removed the closing soon Issue will auto-close if there is no additional activity within 7 days. label Nov 6, 2019
@trivedishivang
Copy link

trivedishivang commented Nov 6, 2019

@kvasukib
aws_sdk_version = '2.16.3'
In our case we have disabled signup verification and the code on Android is below

AWSMobileClient.getInstance().signUp(lowerCaseLogin, pw, new HashMap<>(), validationData, new Callback<SignUpResult>() {
            @Override
            public void onResult(SignUpResult result) {
                Log.v(TAG,"SUCCESS : " + result.toString());
                AWSMobileClient.getInstance().signIn(lowerCaseLogin, pw, null, new Callback<SignInResult>() {
                    @Override
                    public void onResult(SignInResult result) {                       
                        onAuthSuccess();
                    }

                    @Override
                    public void onError(Exception e) {
                        loginError.setText(getString(R.string.createError));
                    }
                });
            }

            @Override
            public void onError(Exception e) {
                Log.v(TAG,"FAIL : " + e.toString());
                loginError.setText(getString(R.string.createUserExists));
            }
        });

The error is : java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.amazonaws.services.cognitoidentityprovider.model.CodeDeliveryDetailsType.getDestination()' on a null object reference.

Let me know if you need more info. Does this prevail for you @SubirZ

@trivedishivang
Copy link

I am by passing the error on SignUp. But can you verify this on your your end @kvasukib . Has the usage changed since then? Thanks!

@mutablealligator mutablealligator removed their assignment Dec 16, 2019
@UbaidKhan91
Copy link

UbaidKhan91 commented Apr 23, 2020

fun changePassword(existingPassword: String, newPassword: String) {

        getActivityContext()?.showLoader()

        AWSMobileClient.getInstance().changePassword(existingPassword, newPassword, object : Callback<Void> {

                override fun onResult(signInResult: Void?) {
                    ThreadUtils.runOnUiThread(Runnable {
                        getActivityContext()?.hideLoader()
                        getActivityContext()?.onBackPressed()
                    })
                }

                override fun onError(e: Exception) {
                    ThreadUtils.runOnUiThread(Runnable {
                        Log.d("errorAWS",e.toString())

                        login()

                    })
                }
            })
    }

Error

    java.lang.NullPointerException: Attempt to invoke virtual method 'com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool.getCurrentUser()' on a null object reference

@TrekSoft
Copy link
Contributor

Hi @UbaidKhan91 - that's a different error than the one being discussed here which may be caused by calling changePassword while being logged out (you need to be logged in to use that method). Could you please check that and if it's still a problem, create a new ticket?

@trivedishivang - Is your issue still happening in the latest version of the SDK?

@richardmcclellan
Copy link
Contributor

richardmcclellan commented Jul 15, 2021

Resolving as it sounds like the original issue has been resolved here, and there has been no response on the follow up question above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mobile client Issues with AWS Mobile's client-side Cognito wrapper
Projects
None yet
Development

No branches or pull requests

6 participants