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

Keep service exception constructors after R8 minification #3466

Open
ede-wolf-gls opened this issue Nov 10, 2023 · 3 comments
Open

Keep service exception constructors after R8 minification #3466

ede-wolf-gls opened this issue Nov 10, 2023 · 3 comments
Labels
bug Something isn't working cognito Issues with the AWS Android SDK for Cognito

Comments

@ede-wolf-gls
Copy link

ede-wolf-gls commented Nov 10, 2023

Describe the bug
With minification enabled, my app gets different exceptions when a user tries to login.

To Reproduce

  • Rely on com.amazonaws.services.cognitoidentity.model.NotAuthorizedException for not authorized users
  • Enable minification in android app
  • app gets a different exception

Current workaround: I added

-keep class * extends com.amazonaws.AmazonServiceException { <init>(java.lang.String); }

in my proguard file.

Which AWS service(s) are affected?
Cognito
com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.73.0

Expected behavior
Even with minification, the app should receive the same exception as without minification.

Screenshots

Environment Information (please complete the following information):

  • AWS Android SDK Version: 2.73.0
  • Device: Samsung Galaxy A40
  • Android Version: 9
  • Specific to simulators: No
@tylerjroach
Copy link
Contributor

@ede-wolf-gls What error are you instead getting with minification? I've tried to replicate but haven't seen minification break exceptions I've checked against yet.

@tylerjroach tylerjroach added bug Something isn't working cognito Issues with the AWS Android SDK for Cognito labels Nov 14, 2023
@ede-wolf-gls
Copy link
Author

The stacktrace looks like this:

com.amazonaws.AmazonClientException: Unable to unmarshall error response (com.amazonaws.services.cognitoidentityprovider.model.NotAuthorizedException.<init> [class java.lang.String]). Response Code: 400, Response Text: Bad Request, Response Headers: {X-Android-Selected-Protocol=http/1.1, x-amzn-ErrorMessage=Incorrect username or password., Connection=keep-alive, x-amzn-ErrorType=NotAuthorizedException:, x-amzn-RequestId=<...>, X-Android-Response-Source=NETWORK 400, X-Android-Sent-Millis=1699609649248, Content-Length=79, X-Android-Received-Millis=1699609649348, Date=Fri, 10 Nov 2023 09:47:32 GMT, Content-Type=application/x-amz-json-1.1}
	 at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:736)
	 at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:420)
	 at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:229)
	 at com.amazonaws.services.cognitoidentityprovider.AmazonCognitoIdentityProviderClient.invoke(AmazonCognitoIdentityProviderClient.java:6849)
	 at com.amazonaws.services.cognitoidentityprovider.AmazonCognitoIdentityProviderClient.respondToAuthChallenge(AmazonCognitoIdentityProviderClient.java:5313)
	 at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser.respondToChallenge(CognitoUser.java:2924)
	 at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser$24.run(CognitoUser.java:3003)
	 at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser$7$1.run(CognitoUser.java:1172)
	 at java.lang.Thread.run(Thread.java:764)

Caused by:
java.lang.NoSuchMethodException: com.amazonaws.services.cognitoidentityprovider.model.NotAuthorizedException.<init> [class java.lang.String]
	 at java.lang.Class.getConstructor0(Class.java:2328)
	 at java.lang.Class.getConstructor(Class.java:1725)
	 at com.amazonaws.transform.AbstractErrorUnmarshaller.newException(AbstractErrorUnmarshaller.java:66)
	 at com.amazonaws.transform.JsonErrorUnmarshaller.unmarshall(JsonErrorUnmarshaller.java:53)
	 at com.amazonaws.services.cognitoidentityprovider.model.transform.NotAuthorizedExceptionUnmarshaller.unmarshall(NotAuthorizedExceptionUnmarshaller.java:37)
	 at com.amazonaws.http.JsonErrorResponseHandler.runErrorUnmarshallers(JsonErrorResponseHandler.java:98)
	 at com.amazonaws.http.JsonErrorResponseHandler.handle(JsonErrorResponseHandler.java:67)
	 at com.amazonaws.http.JsonErrorResponseHandler.handle(JsonErrorResponseHandler.java:35)
	 at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:711)
	 at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:420)
	 at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:229)
	 at com.amazonaws.services.cognitoidentityprovider.AmazonCognitoIdentityProviderClient.invoke(AmazonCognitoIdentityProviderClient.java:6849)
	 at com.amazonaws.services.cognitoidentityprovider.AmazonCognitoIdentityProviderClient.respondToAuthChallenge(AmazonCognitoIdentityProviderClient.java:5313)
	 at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser.respondToChallenge(CognitoUser.java:2924)
	 at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser$24.run(CognitoUser.java:3003)
	 at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser$7$1.run(CognitoUser.java:1172)
	 at java.lang.Thread.run(Thread.java:764)

@tylerjroach
Copy link
Contributor

Thank you, will look to add the rule. In the meantime, please continue with the manual addition to your proguard config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cognito Issues with the AWS Android SDK for Cognito
Projects
None yet
Development

No branches or pull requests

2 participants