Closed dorontal closed 2 years ago
@dorontal - thank you for creating this ticket so promptly - we will check this out!
Sounds great, thanks so much @abdallahshaban557 - FYI: this happened after a routine upgrade of the CLI and all SDK libraries, which I do about once per week. The upgrade went from version 10.2.1 to 10.2.3 when this happened.
understood - saw that comment from you on the previous issue and I have passed that info to our support team! We will get back to you!
@dorontal I wasn't able to reproduce this issue even after upgrading CLI and setting up a new Amplify backend with the new CLI. After you upgraded the CLI, did you run any amplify commands like push/pull? If so, did you make any backend updates first? I'm trying to better understand how CLI update might be connected here and eventually reproduce.
Looking at https://github.com/aws-amplify/amplify-flutter/issues/385 am wondering if you tried running flutter clean
and restarting vscode?
@ragingsquirrel3 I did see #385 and did try the flutter clean
followed by a VSCode restart but to no avail. You mean you used all new versions to create a new project and then to cause in it an Amplify exception and you were able to catch such exceptions with a try-catch? That's interesting. It does not work for me. Amplify exceptions such as StorageException
or AuthException
cannot be caught right now in my code and this started right after the upgrade without any changes to the code.
Yes, I created a new amplify project after updating to newest CLI version, ran app in android and performed an operation that throws an exception. I was able to catch the exception as AuthException
without issue so not sure how I can reproduce this. This is so far only on Android, correct?
Yes, only tested this on the usual Android emulator and I don't have a way to test on iOS. Thanks very much for clarifying. I did try to re-install everything from scratch (amplify folder, cli, libraries) and restarted but got the same error. If this persists, I will create a small app that demonstrates it.
@dorontal have you tried manually downgrading your Amplify CLI to the version you used before? Also, did you run amplify push/pull after updating it? CLI update by itself would be very strange cause unless it updated backend/config file with new version (which would still be strange). I don't understand how CLI update would cause this kind of error but as a sanity check might be good to try the old version so not to focus on CLI version if that's not really root cause.
@ragingsquirrel3 I understand and also find it counterintuitive that a CLI upgrade would cause a bug in exception handling code. I have another machine with CLI version 10.0.0 installed on it. I copied the entire project over and it ran flawlessly on that machine as-is without a change. Several exceptions got called, e.g. when getCurrentUser()
was called while nobody was logged in and these exceptions now get caught/handled just fine on the other machine. If I have time to look further into the differences between these two, I will, but probably would just prefer to continue working for now. At some point I'll run amplify upgrade
on the other machine where things currently work with version 10.0.0 and will report if the upgrade breaks things, but it wasn't just a CLI upgrade after which this issue showed up, it was a CLI upgrade plus a rebuild (automatic, via expect scripts) of everything after an amplify delete
.
@ragingsquirrel3 I never figured out why exception handling temporarily failed after the upgrade of Amplify libraries to version 0.6.8
and of the CLI from version 10.2.1
to 10.2.3
(it wasn't just a CLI upgrade before as I had indicated).
But after upgrading to CLI version 10.3.0
(also later to 10.3.1
) and to the library versions 0.6.9
and everything works as expected - exceptions can be caught. I believe this issue can be closed now. Thanks for your help. Please feel free to close this.
Glad this issue went away and thanks for the info.
Description
Amplify exceptions cannot be caught -- they show up as "platform exceptions" and the error thrown "Translating platform exception failed" cannot be caught in the client code.
For example, here is the complaint I get in VSCode in red when an exception is not caught and the app crashes -- after trying to get a file from S3 which does not exist:
All your exceptions are showing up as this
PlatformException
wrapped object that generates errors like the above when you try to catch an Amplify exception in the client app code.Categories
Steps to Reproduce
Just run any skeleton app and cause an Amplify exception in your code. E.g. use this code
while no user is signed in to generate an amplify "user not signed in" exception - put a breakpoint in the catch block and the exception will not be caught. You will get the app crashing with a complaint very similar to what you see in this issue: https://github.com/aws-amplify/amplify-flutter/issues/385
Screenshots
No response
Platforms
Android Device/Emulator API Level
API 29, API 31
Environment
Dependencies
Device
Android Emulator
OS
Android 8
Deployment Method
Amplify CLI
CLI Version
10.2.3
Additional Context
This happened as soon as I upgraded the CLI from version 10.2.1 to 10.2.3
Amplify Config
const amplifyconfig = ''' { "UserAgent": "aws-amplify-cli/2.0", "Version": "1.0", "api": { "plugins": { "awsAPIPlugin": { "tracktunes": { "endpointType": "GraphQL", "endpoint": "https://?????????????.appsync-api.us-east-1.amazonaws.com/graphql", "region": "us-east-1", "authorizationType": "AWS_IAM" }, "tracktunesCognito": { "endpointType": "GraphQL", "endpoint": "https://?????????????.appsync-api.us-east-1.amazonaws.com/graphql", "region": "us-east-1", "authorizationType": "AMAZON_COGNITO_USER_POOLS" }, "lambdaFunctions": { "endpointType": "REST", "endpoint": "https://?????????.execute-api.us-east-1.amazonaws.com/dev", "region": "us-east-1", "authorizationType": "AWS_IAM" }, "lambdaFunctionsCognito": { "endpointType": "REST", "endpoint": "https://?????????.execute-api.us-east-1.amazonaws.com/dev", "region": "us-east-1", "authorizationType": "AMAZON_COGNITO_USER_POOLS" } } } }, "auth": { "plugins": { "awsCognitoAuthPlugin": { "UserAgent": "aws-amplify-cli/0.1.0", "Version": "0.1.0", "IdentityManager": { "Default": {} }, "CredentialsProvider": { "CognitoIdentity": { "Default": { "PoolId": "us-east-1:??????????????????????", "Region": "us-east-1" } } }, "CognitoUserPool": { "Default": { "PoolId": "us-east-1_fQp7Vz93X", "AppClientId": "???????????????????", "Region": "us-east-1" } }, "Auth": { "Default": { "authenticationFlowType": "USER_SRP_AUTH", "socialProviders": [], "usernameAttributes": [ "EMAIL" ], "signupAttributes": [ "EMAIL" ], "passwordProtectionSettings": { "passwordPolicyMinLength": 8, "passwordPolicyCharacters": [] }, "mfaConfiguration": "OFF", "mfaTypes": [ "SMS" ], "verificationMechanisms": [ "EMAIL" ] } }, "AppSync": { "Default": { "ApiUrl": "https://?????????????.appsync-api.us-east-1.amazonaws.com/graphql", "Region": "us-east-1", "AuthMode": "AWS_IAM", "ClientDatabasePrefix": "tracktunes_AWS_IAM" }, "tracktunes_AMAZON_COGNITO_USER_POOLS": { "ApiUrl": "https://?????????????.appsync-api.us-east-1.amazonaws.com/graphql", "Region": "us-east-1", "AuthMode": "AMAZON_COGNITO_USER_POOLS", "ClientDatabasePrefix": "tracktunes_AMAZON_COGNITO_USER_POOLS" } }, "S3TransferUtility": { "Default": { "Bucket": "?????????????", "Region": "us-east-1" } } } } }, "storage": { "plugins": { "awsS3StoragePlugin": { "bucket": "?????????????", "region": "us-east-1", "defaultAccessLevel": "guest" } } } }''';