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

fix(Core): Fix plugin configuration validation #543

Merged
merged 3 commits into from Jun 16, 2020

Conversation

palpatim
Copy link
Member

Previous validation logic threw an error if it encountered a configuration
stanza with no corresponding plugin registered for that key. However, the
current CLI emits some plugin keys in unexpected situations, breaking this
validation. Remediation would require a customer to edit the config file, which
is possibly dangerous, and definitely inconvenient.

This change:

  • Replaces the throwing error with a logged warning when the config encounters
    an unmatched plugin key
  • Changes the Plugin.configure signature to accept an optional Any?
    argument, instead of a non-optional. This will let plugins decide if they
    need to throw or not.
  • Fixes a data race in hub test code
  • Fix AWSCognitoAuthPlugin and AWSS3StoragePlugin to throw a PluginError
    instead of a category-specific error if they encounter an error during
    configuration

Issue #, if available:

#540

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

Previous validation logic threw an error if it encountered a configuration
stanza with no corresponding plugin registered for that key. However, the
current CLI emits some plugin keys in unexpected situations, breaking this
validation. Remediation would require a customer to edit the config file, which
is possibly dangerous, and definitely inconvenient.

This change:
- Replaces the throwing error with a logged warning when the config encounters
  an unmatched plugin key
- Changes the `Plugin.configure` signature to accept an optional `Any?`
  argument, instead of a non-optional. This will let plugins decide if they
  need to throw or not.
- Fixes a data race in hub test code
- Fix AWSCognitoAuthPlugin and AWSS3StoragePlugin to throw a PluginError
  instead of a category-specific error if they encounter an error during
  configuration

fixes #540
@palpatim palpatim requested a review from lawmicha June 12, 2020 23:55
@palpatim palpatim added this to the 1.0.2 milestone Jun 15, 2020
Amplify/Core/Configuration/AmplifyConfiguration.swift Outdated Show resolved Hide resolved
Comment on lines +14 to +16
// Note this test requires the ability to write a new database in the Documents directcory, so it must be embedded
// in a host app
func testDoesNotThrowOnMissingConfig() throws {
Copy link
Member

Choose a reason for hiding this comment

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

unrelated to this PR, leaving a note for @DongQuanRui this looks like the right place to put tests for the configuring DataStore when schema version changes

@palpatim palpatim merged commit d526c61 into master Jun 16, 2020
@palpatim palpatim deleted the palpatim/fix-plugin-config-validation branch June 16, 2020 17:22
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

Successfully merging this pull request may close these issues.

None yet

2 participants