Skip to content

Conversation

@5d
Copy link
Contributor

@5d 5d commented May 14, 2024

Issue #

Description

The AWSAuthModeStrategy determines how AppSync requests are executed. It may attempt multiple AWS authentication modes to complete the request, retrying the next mode in the sequence if the previous one encounters an unauthorized error.

However, the auth mode sequence relies on nil element to determine the end of the sequence. Additionally, the AppSync request factory also uses the special value nil to determine whether to try the default authentication mode configured in the amplifyconfiguration file.

Using nil to mark the end of a sequence is part of Apple's standard library. In this PR, we introduced a new enum value 'inferred' to serve this purpose instead of relying on nil.

General Checklist

  • Added new tests to cover change, if needed
  • Build succeeds with all target using Swift Package Manager
  • All unit tests pass
  • All integration tests pass
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
  • Documentation update for the change if required
  • PR title conforms to conventional commit style
  • New or updated tests include Given When Then inline code documentation and are named accordingly testThing_condition_expectation()
  • If breaking change, documentation/changelog update with migration instructions

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

@codecov
Copy link

codecov bot commented May 14, 2024

Codecov Report

Attention: Patch coverage is 82.14286% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 68.60%. Comparing base (cf7fe31) to head (060b5f6).

Files Patch % Lines
...Core/AWSPluginsCore/Auth/AWSAuthModeStrategy.swift 71.42% 4 Missing ⚠️
...Plugin/Sync/InitialSync/InitialSyncOperation.swift 78.94% 4 Missing ⚠️
...ries/API/Operation/RetryableGraphQLOperation.swift 50.00% 1 Missing ⚠️
...Sync/IncomingAsyncSubscriptionEventPublisher.swift 93.33% 1 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           flutter-datastore-v2    #3694      +/-   ##
========================================================
+ Coverage                 68.46%   68.60%   +0.14%     
========================================================
  Files                      1078     1079       +1     
  Lines                     37552    37550       -2     
========================================================
+ Hits                      25709    25761      +52     
+ Misses                    11843    11789      -54     
Flag Coverage Δ
API_plugin_unit_test 68.76% <ø> (-0.22%) ⬇️
AWSPluginsCore 68.56% <77.77%> (+0.34%) ⬆️
Amplify 47.68% <50.00%> (-0.19%) ⬇️
Analytics_plugin_unit_test 84.52% <ø> (ø)
Auth_plugin_unit_test 79.32% <ø> (-0.02%) ⬇️
DataStore_plugin_unit_test 82.30% <86.11%> (+0.98%) ⬆️
Geo_plugin_unit_test 72.00% <ø> (ø)
Logging_plugin_unit_test 62.87% <ø> (ø)
Predictions_plugin_unit_test 37.32% <ø> (ø)
PushNotifications_plugin_unit_test 86.21% <ø> (ø)
Storage_plugin_unit_test 76.75% <ø> (ø)
unit_tests 68.60% <82.14%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@5d 5d changed the title refactor(datastore): new enum to represent inferred and designated au… refactor(datastore): new enum to represent inferred and designated authType May 14, 2024
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 22:57 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
@5d 5d temporarily deployed to IntegrationTest May 14, 2024 23:35 — with GitHub Actions Inactive
for authType in authTypes {
continuation.yield({ [weak self] in
guard let self, let api = self.api else {
throw APIError.operationError("Operation cancelled", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

we should improve this error message so it will be easier to match to this code if customers give us logs with this

Copy link
Contributor Author

@5d 5d May 16, 2024

Choose a reason for hiding this comment

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

yeah, this is when captured self is no longer exist, probably cancelled by the operation queue. How about this:
The initial synchronization process can no longer be accessed or referred to

@5d 5d force-pushed the 5d/refactor-auth-types branch from 096b474 to 80411e2 Compare May 16, 2024 19:58
@5d 5d marked this pull request as ready for review May 16, 2024 20:13
@5d 5d requested a review from a team as a code owner May 16, 2024 20:13
@5d 5d requested a review from lawmicha May 16, 2024 20:27
@5d 5d force-pushed the 5d/refactor-auth-types branch from 80411e2 to 060b5f6 Compare May 21, 2024 20:55
@5d 5d merged commit 82f9ec5 into flutter-datastore-v2 May 29, 2024
@5d 5d deleted the 5d/refactor-auth-types branch May 29, 2024 17:12
5d added a commit that referenced this pull request Jun 3, 2024
…LBehavior (#3666)

* WIP

* DataStore compiles without SDK dependency

* refactor(datastore-v2): use api plugin with async sequences

* change to use Publisher operators for auth type streams

* add nondeterminsitc operation for better testability

* fix unit test cases

* fix broken unit test cases of AWSAPIPlugin

* fix broken AWSDataStorePlugin unit test cases

* fix OutgoingMutationQueue test case

* remove unused methods

* fix broken test cases of SyncMutationToCloudOperationTests

* fix broken unit test cases of API and DataStore

* resolve plugins build issues (#3654)

* remove lock from SyncMutationToCloudOperation

* remove test case of retryable for signOut error

* resolve comments

* fix(datastore): propagate remote mutationEvents to Hub for sync received (#3697)

* rename the package to InternalAmplifyCredentials

* rewrite NondeterminsticOperation constructor with makeStream

* resolve broken test case after merging latest orgin/main

* feat(amplify): make GraphQLOperationType extends from String (#3719)

* refactor(datastore): new enum to represent inferred and designated authType (#3694)

* refactor(datastore): new enum to represent inferred and designated auth type

* resolve failed multi auth integ tests

* resolve comments

* fix(datastore): use error description to produce clearer error info (#3733)

---------

Co-authored-by: Michael Law <[email protected]>
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.

2 participants