[PR #1861] [MERGED] Fix for missing token when checking for key connector migration #3188

Closed
opened 2025-11-26 23:29:26 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1861
Author: @mpbw2
Created: 3/24/2022
Status: Merged
Merged: 3/24/2022
Merged by: @mpbw2

Base: masterHead: bugfix-keyconnector-token-external


📝 Commits (1)

  • bcb0883 Fix for missing token when checking for key connector migration

📊 Changes

1 file changed (+4 additions, -0 deletions)

View changed files

📝 src/Core/Services/TokenService.cs (+4 -0)

📄 Description

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

Crash data from both platforms show a common thread where TokenService.DecodeToken is throwing Access token not found when called from KeyConnectorService.UserNeedsMigration > TokenService.GetIsExternal. Based on the 1:1 ratio of users to crashes, this seems like a race condition that occurs once before an active account token is written to storage. An additional null check of _accessTokenForDecoding before calling DecodeToken from GetIsExternal (following the same logic of the decoded?["amr"] null check immediately below it) should prevent this.

Code changes

  • TokenService.cs: Return false if _accessTokenForDecoding if still null after GetTokenAsync and before DecodeToken

Testing requirements

Before you submit

  • I have added unit tests where it makes sense to do so (encouraged but not required)
  • This change requires a documentation update (notify the documentation team)
  • This change has particular deployment requirements (notify the DevOps team)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/1861 **Author:** [@mpbw2](https://github.com/mpbw2) **Created:** 3/24/2022 **Status:** ✅ Merged **Merged:** 3/24/2022 **Merged by:** [@mpbw2](https://github.com/mpbw2) **Base:** `master` ← **Head:** `bugfix-keyconnector-token-external` --- ### 📝 Commits (1) - [`bcb0883`](https://github.com/bitwarden/android/commit/bcb088377c92920cb763ae1a510d79db8c57be70) Fix for missing token when checking for key connector migration ### 📊 Changes **1 file changed** (+4 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/Core/Services/TokenService.cs` (+4 -0) </details> ### 📄 Description ## Type of change - [X] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> Crash data from both platforms show a common thread where `TokenService.DecodeToken` is throwing `Access token not found` when called from `KeyConnectorService.UserNeedsMigration` > `TokenService.GetIsExternal`. Based on the 1:1 ratio of users to crashes, this seems like a race condition that occurs once before an active account token is written to storage. An additional null check of `_accessTokenForDecoding` before calling `DecodeToken` from `GetIsExternal` (following the same logic of the `decoded?["amr"]` null check immediately below it) should prevent this. ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> * **TokenService.cs:** Return `false` if `_accessTokenForDecoding` if still null after `GetTokenAsync` and before `DecodeToken` ## Testing requirements <!--What functionality requires testing by QA? This includes testing new behavior and regression testing--> ## Before you submit - [ ] I have added **unit tests** where it makes sense to do so (encouraged but not required) - [ ] This change requires a **documentation update** (notify the documentation team) - [ ] This change has particular **deployment requirements** (notify the DevOps team) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:29:26 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#3188