Skip to content

fix: Plugins that are not configured correctly will be error at initial step #642

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

Merged
merged 6 commits into from
Jul 15, 2020

Conversation

royjit
Copy link
Contributor

@royjit royjit commented Jul 15, 2020

Issue #480

Description of changes:

This change allows to call configure method of each plugin with a nil value. ie even if the corresponding configuration is not present in the configuration file, plugin's configure will be called.

Issue we are solving:

Suppose that I added two plugins to my project AWSAPIPlugin and AWSDataStorePlugin, but forgot to add any configuration for API in my amplifyconfiguration.json. Since there is no configuration the current logic does not invoke the configure(:) function of AWSAPIPlugin. So we end up using a not-configured plugin and end up in unintended error or crash like this - #480

Thought process behind this change:

All category in Amplify conforms to the protocol - CategoryConfigurable, which could infer that the plugins added to every category is configurable. Since each added plugin is configurable it should be given a chance to configure even if the corresponding configuration is missing. This will give the plugin a chance to decide whether it can work in a non-configuration based situation or throw an error.

Other changes in this PR

  • Fixed an error in storage unit test that caused it to fail when whole storage unit test is executed.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@royjit royjit self-assigned this Jul 15, 2020
@royjit royjit added the core Amplify Core components label Jul 15, 2020
@royjit royjit marked this pull request as ready for review July 15, 2020 17:06
Copy link
Member

@palpatim palpatim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor naming change, otherwise LGTM

try plugin.configure(using: nil)
XCTFail("Analytics configuration should not succeed")
} catch {
guard let apiError = error as? PluginError,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we're not really throwing an API error here, it's just a misnamed variable?

try plugin.configure(using: nil)
XCTFail("Auth configuration should not succeed")
} catch {
guard let apiError = error as? PluginError,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and throughout: fix name

@royjit royjit merged commit d045aa4 into main Jul 15, 2020
@royjit royjit deleted the fix-gh480 branch July 15, 2020 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Amplify Core components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants