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

Could not initialize Amplify: PluginError: Unable to decode configuration Recovery suggestion: Make sure the plugin configuration is JSONValue #3196

Closed
evan1108 opened this issue Aug 30, 2023 · 3 comments

Comments

@evan1108
Copy link

evan1108 commented Aug 30, 2023

Describe the bug

I'm experiencing the following error when I try to run try Amplify.configure(). This seems sporadic as running my app locally was working, but after starting and stopping multiple simulations I encountered the error. I've followed the initialization instructions here and here.

I even created a new project and re-initialized a new amplify project, but the error eventually appears again (appeared on my fourth re-run). Error:
Could not initialize Amplify: PluginError: Unable to decode configuration Recovery suggestion: Make sure the plugin configuration is JSONValue

My awsconfiguration and amplifyconfiguration JSON files are included in my XCode project. I've pasted them below (replacing personal information) - they are in valid JSON format.

awsconfiguration:

{
    "UserAgent": "aws-amplify/cli",
    "Version": "0.1.0",
    "IdentityManager": {
        "Default": {}
    },
    "AppSync": {
        "Default": {
            "ApiUrl": "https://<value>.appsync-api.us-west-2.amazonaws.com/graphql",
            "Region": "us-west-2",
            "AuthMode": "API_KEY",
            "ApiKey": "<value>",
            "ClientDatabasePrefix": "siftshopping_API_KEY"
        }
    },
    "CredentialsProvider": {
        "CognitoIdentity": {
            "Default": {
                "PoolId": "us-west-2:........-....-....-....-............",
                "Region": "us-west-2"
            }
        }
    },
    "CognitoUserPool": {
        "Default": {
            "PoolId": "us-west-2_Fl9SqGnmK",
            "AppClientId": "66sk9sl4rb5nrmfs74vnag3bme",
            "Region": "us-west-2"
        }
    },
    "Auth": {
        "Default": {
            "OAuth": {
                "WebDomain": "<value>-dev.auth.us-west-2.amazoncognito.com",
                "AppClientId": <value>,
                "SignInRedirectURI": "<value>://",
                "SignOutRedirectURI": "<value>://",
                "Scopes": [
                    "phone",
                    "email",
                    "openid",
                    "profile",
                    "aws.cognito.signin.user.admin"
                ]
            },
            "authenticationFlowType": "USER_SRP_AUTH",
            "socialProviders": [],
            "usernameAttributes": [
                "EMAIL",
                "PHONE_NUMBER"
            ],
            "signupAttributes": [
                "EMAIL"
            ],
            "passwordProtectionSettings": {
                "passwordPolicyMinLength": 8,
                "passwordPolicyCharacters": []
            },
            "mfaConfiguration": "OFF",
            "mfaTypes": [
                "SMS"
            ],
            "verificationMechanisms": [
                "EMAIL"
            ]
        }
    }
}

amplifyconfiguration:

{
    "UserAgent": "aws-amplify-cli/2.0",
    "Version": "1.0",
    "api": {
        "plugins": {
            "awsAPIPlugin": {
                "siftshopping": {
                    "endpointType": "GraphQL",
                    "endpoint": "https://<value>.appsync-api.us-west-2.amazonaws.com/graphql",
                    "region": "us-west-2",
                    "authorizationType": "API_KEY",
                    "apiKey": "<value>"
                }
            }
        }
    },
    "auth": {
        "plugins": {
            "awsCognitoAuthPlugin": {
                "UserAgent": "aws-amplify/cli",
                "Version": "0.1.0",
                "IdentityManager": {
                    "Default": {}
                },
                "AppSync": {
                    "Default": {
                        "ApiUrl": "https://<value>.appsync-api.us-west-2.amazonaws.com/graphql",
                        "Region": "us-west-2",
                        "AuthMode": "API_KEY",
                        "ApiKey": "<value>",
                        "ClientDatabasePrefix": "siftshopping_API_KEY"
                    }
                },
                "CredentialsProvider": {
                    "CognitoIdentity": {
                        "Default": {
                            "PoolId": "us-west-2:<value>",
                            "Region": "us-west-2"
                        }
                    }
                },
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "us-west-2_<value>",
                        "AppClientId": "<value>",
                        "Region": "us-west-2"
                    }
                },
                "Auth": {
                    "Default": {
                        "OAuth": {
                            "WebDomain": "<value>-dev.auth.us-west-2.amazoncognito.com",
                            "AppClientId": "<value>",
                            "SignInRedirectURI": "<value>://",
                            "SignOutRedirectURI": "<value>://",
                            "Scopes": [
                                "phone",
                                "email",
                                "openid",
                                "profile",
                                "aws.cognito.signin.user.admin"
                            ]
                        },
                        "authenticationFlowType": "USER_SRP_AUTH",
                        "socialProviders": [],
                        "usernameAttributes": [
                            "EMAIL",
                            "PHONE_NUMBER"
                        ],
                        "signupAttributes": [
                            "EMAIL"
                        ],
                        "passwordProtectionSettings": {
                            "passwordPolicyMinLength": 8,
                            "passwordPolicyCharacters": []
                        },
                        "mfaConfiguration": "OFF",
                        "mfaTypes": [
                            "SMS"
                        ],
                        "verificationMechanisms": [
                            "EMAIL"
                        ]
                    }
                }
            }
        }
    }
}

Steps To Reproduce

Steps to reproduce the behavior:
1. Initialize an amplify project with the Amplify, AWSAPIPlugin, AWSCognitoAuthPlugin, AWSS3StoragePlugin
2. Attempt to add the plugins to amplify and configure: 
            try Amplify.add(plugin: AWSCognitoAuthPlugin())
            try Amplify.add(plugin: AWSS3StoragePlugin())
            try Amplify.add(plugin: AWSAPIPlugin(modelRegistration: AmplifyModels()))
            try Amplify.configure()
3. Run the app in XCode. Stop, make changes to Views, re-build and re-run the app. On the fourth run, it fails.
4. See error
Could not initialize Amplify: PluginError: Unable to decode configuration
Recovery suggestion: Make sure the plugin configuration is JSONValue

Expected behavior

I expect the app to build and run successfully, consistently.

Amplify Framework Version

2.15.3

Amplify Categories

API, Auth, Storage

Dependency manager

Swift PM

Swift version

5.8

CLI version

11.1.1

Xcode version

14.3

Relevant log output

<details>
<summary>Log Messages</summary>


Could not initialize Amplify: PluginError: Unable to decode configuration
Recovery suggestion: Make sure the plugin configuration is JSONValue
```

Is this a regression?

No

Regression additional context

No response

Platforms

iOS

OS Version

iOS 16.2

Device

iPhone 13 Pro, iPhone 14 Pro

Specific to simulators

No response

Additional context

No response

@5d 5d added the pending-triage Issue is pending triage label Aug 30, 2023
@5d
Copy link
Member

5d commented Aug 30, 2023

Thanks for opening this issue. @evan1108

The team will investigate and get back to you as soon as we have more information.

@5d
Copy link
Member

5d commented Aug 30, 2023

Hi @evan1108 ,

It seems you forgot to setup the backend for storage plugin. There should be a section like the example below in your amplifyconfiguration.json.

"storage": {
    "plugins": {
        "awsS3StoragePlugin": {
            "bucket": "<bucket-name>",
            "region": "<aws-region>",
            ...
        }
    }
}

You can follow this doc to setup your storage backend.

@5d 5d removed the pending-triage Issue is pending triage label Aug 30, 2023
@evan1108
Copy link
Author

You're right! I removed the storage backend but didn't remove from my code. Thank you! Builds fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants