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(DataStore): retry MutationEvents on signed-out and token expired errors #3487

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

lawmicha
Copy link
Member

@lawmicha lawmicha commented Jan 29, 2024

Issue #

Continuation from #3259 (comment)

Description

This PR is a change in DataStore's SyncMutationToCloudOperation to determine whether mutation events are retryable.

  1. A mutation event is deemed retryable when the underlying auth error is AuthError.signedOut. If the user is signed out, we could not attempt the request and therefore, should be retried.
  2. A mutation event should be retried on session expired. Changes to API plugin returns API.operationError with underlying AuthError.sessionExpired when the token is expired. If authService provides APIPlugin with an expired token, it will fail fast during the request interception, and pass this error back. No additional changes necessary needed in DataStore since it is already retrying on session expired from a previous PR.

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.

@lawmicha lawmicha requested a review from a team as a code owner January 29, 2024 17:47
Copy link
Member

@thisisabhash thisisabhash left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-commenter
Copy link

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (a512b2e) 68.06% compared to head (36d5e8d) 67.93%.

Files Patch % Lines
...gin/Configuration/AWSAPIEndpointInterceptors.swift 90.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3487      +/-   ##
==========================================
- Coverage   68.06%   67.93%   -0.13%     
==========================================
  Files        1080     1080              
  Lines       36388    36406      +18     
==========================================
- Hits        24767    24732      -35     
- Misses      11621    11674      +53     
Flag Coverage Δ
API_plugin_unit_test 67.23% <94.44%> (+0.15%) ⬆️
AWSPluginsCore 64.18% <ø> (ø)
Amplify 48.10% <ø> (-0.02%) ⬇️
Analytics_plugin_unit_test 81.16% <ø> (ø)
Auth_plugin_unit_test 78.96% <ø> (-0.02%) ⬇️
CoreMLPredictions_plugin_unit_test 59.44% <ø> (ø)
DataStore_plugin_unit_test 80.53% <100.00%> (-0.73%) ⬇️
Geo_plugin_unit_test 70.75% <ø> (ø)
Logging_plugin_unit_test 63.34% <ø> (ø)
Predictions_plugin_unit_test 37.16% <ø> (ø)
PushNotifications_plugin_unit_test 87.13% <ø> (ø)
Storage_plugin_unit_test 77.51% <ø> (ø)
unit_tests 67.93% <97.14%> (-0.13%) ⬇️

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.

@lawmicha lawmicha merged commit f64c471 into main Jan 30, 2024
79 checks passed
@lawmicha lawmicha deleted the lawmicha.fix-sign-out-token-expiry branch January 30, 2024 14:14
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.

3 participants