aws / aws-toolkit-jetbrains

AWS Toolkit for JetBrains - a plugin for interacting with AWS from JetBrains IDEs
https://plugins.jetbrains.com/plugin/11349-aws-toolkit
Apache License 2.0
730 stars 198 forks source link

Q Code Transform: Fix failed uploads and downloads when credentials expire #4573

Closed arangatang closed 2 weeks ago

arangatang commented 3 weeks ago

Types of changes

Description

~11% of API failures in May are due to expired credentials being used (InvalidGrantException). The most common places in the code where this happens is when users are about to upload their code or when about to download the code. This is due to at these points customers may have been inactive for a substantial amount of time (>15 min) either due to long running mvn builds or due to being afk before downloading results.

This PR fixes this by forcing a refresh through chat when token is marked as NEED_REFRESH or if we get a SssOidcException. Additionally in the case of downloading an archive we need to resume the job after credential refresh such that users can reattempt the download. Detailed flow for the two cases detailed below:

Flow when token expired when calling CreateUpload:

  1. Chat asks user to reauthenticate
  2. Notification asks user to reauthenticate
  3. Clicking either causes reauthentication flow to run
  4. When user successfully authenticates then the user is requested to start a new flow

Flow when token expired before calling ExportResultArchive

  1. Chat asks user to reauthenticate
  2. Notification asks user to reauth
  3. Clicking either causes reauthentication flow to run
  4. When user authenticates successfully then the job is resumed
  5. When job fully resumes users are notified to download the results again as normal

Misc changes (bugfixes / supporting changes)

  1. [Supporting change] - Tab opens on resume without user needing to enter /transform
  2. [Supporting change] - Added BearerToken listener to listen for authentication successes so that chat could be informed when user reauthenticates
  3. [Bug fix / Supporting change] - Removed notification “Job completed when you were away” as it was a duplicate and messes up resume flow (as users can click while we are attempting to resume job which causes issues in chat)
  4. [Bug fix / Supporting change] - Removed notification “Job failed when you were away” as it was a duplicate and messes up resume flow (as users can click while we are attempting to resume job which causes issues in chat)
  5. [Bug fix] - Removed notification when job failed during download when more specific error notifications are already shown.

Checklist

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

arangatang commented 3 weeks ago

Upload failure

  1. Before reauth

    Screenshot 2024-06-11 at 15 52 32
  2. After reauth

    Screenshot 2024-06-11 at 15 54 14

Download failure

  1. Before clicking view diff after being AFK for 15 min (Idc session duration set to 15 min)

    Screenshot 2024-06-11 at 15 56 41
  2. Immediatelly when clicking view diff with expired credentials

    Screenshot 2024-06-11 at 15 57 07
  3. When reauthenticated successfully transformation is resumed

    Screenshot 2024-06-11 at 15 58 05
  4. When transformation resumed customers have a chance to redownload the results

    Screenshot 2024-06-11 at 15 58 51
  5. Download then succeeds properly since credentials are updated

    Screenshot 2024-06-11 at 15 59 33
sonarcloud[bot] commented 3 weeks ago

Quality Gate Passed Quality Gate passed

Issues
10 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.7% Duplication on New Code

See analysis details on SonarCloud

arangatang commented 2 weeks ago

Failing test is:

software.aws.toolkits.jetbrains.services.lambda.dotnet.LambdaGutterMarkHighlightingTest

Which is unrelated to my changes.

rli commented 2 weeks ago

changelog?