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(api): When a mutation response code indicates client error only call onFailure #2255

Conversation

millsjustin
Copy link
Contributor

  • PR title and description conform to Pull Request guidelines.

Currently if a mutation response code indicates a client error (i.e. code >= 400 && code <= 499), both the onFailure and onResponse callbacks are called.

This is problematic when the mutate call is wrapped in a Kotlin coroutine (i.e. like the Kotlin facade), because the continuation resumes with exception when onFailure is called and will throw an exception when attempting to resume without exception.

This PR returns immediately after calling onFailure to avoid calling both callbacks. It also adds a test to ensure both callbacks are not called.

How did you test these changes?
Added unit test

  • Added Unit Tests
  • Added Integration Tests

Documentation update required?

  • No
  • Yes (Please include a PR link for the documentation update)

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

@millsjustin millsjustin requested review from a team as code owners January 25, 2023 20:57
@millsjustin millsjustin force-pushed the jm/mutate-with-client-error-response-should-not-call-onResponse branch from cd457d6 to 4607349 Compare January 25, 2023 20:59
@gpanshu gpanshu self-requested a review July 26, 2023 19:25
@gpanshu gpanshu enabled auto-merge (squash) August 23, 2023 15:44
@codecov-commenter
Copy link

Codecov Report

Merging #2255 (82c235b) into main (f81521f) will increase coverage by 0.03%.
The diff coverage is n/a.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main    #2255      +/-   ##
==========================================
+ Coverage   41.44%   41.47%   +0.03%     
==========================================
  Files         874      874              
  Lines       27643    27643              
  Branches     3883     3883              
==========================================
+ Hits        11457    11466       +9     
+ Misses      14959    14949      -10     
- Partials     1227     1228       +1     

@gpanshu gpanshu merged commit 70b6533 into aws-amplify:main Aug 24, 2023
3 checks passed
gpanshu added a commit that referenced this pull request Aug 24, 2023
…all onFailure (#2255)

Co-authored-by: Matt Creaser <mattwcc@amazon.com>
Co-authored-by: gpanshu <91897496+gpanshu@users.noreply.github.com>
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.

4 participants