[PR #6640] [MERGED] 🍒[PM-33394] fix: Propagate CookieRedirectException error message #54958

Closed
opened 2026-05-01 20:49:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/6640
Author: @SaintPatrck
Created: 3/11/2026
Status: Merged
Merged: 3/11/2026
Merged by: @SaintPatrck

Base: release/2026.3-rc48Head: release/2026.3-rc48_cp-PM-333394


📝 Commits (1)

  • 4d13974 🍒[PM-33394] fix: Propagate CookieRedirectException error message through existing Http error pipeline

📊 Changes

3 files changed (+187 additions, -0 deletions)

View changed files

📝 network/src/main/kotlin/com/bitwarden/network/model/BitwardenError.kt (+21 -0)
network/src/test/kotlin/com/bitwarden/network/model/BitwardenErrorTest.kt (+67 -0)
network/src/test/kotlin/com/bitwarden/network/util/ExceptionExtensionsTest.kt (+99 -0)

📄 Description

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-33394
Cherry-picked from #6639

📔 Objective

When SSO cookies expire in a load-balanced environment, API actions trigger a CookieRedirectException. After the app completes the "Sync with browser" re-authentication flow, a generic error was shown ("We were unable to process your request") instead of the exception's descriptive message ("Your request was interrupted because the app needed to re-authenticate. Please try again.").

Root cause: CookieRedirectException extends IOException, so toBitwardenError() classified it as BitwardenError.Network. The parseErrorBodyOrNull() function only handles BitwardenError.Http, returning null for network errors — causing the message to be lost.

Fix: Updated toBitwardenError() to intercept CookieRedirectException before the generic IOException check (since it's a subclass). Synthesizes a BitwardenError.Http with a 400 response and JSON body containing the exception message, allowing it to flow through the existing parseErrorBodyOrNull pipeline with zero changes to downstream code.

Scope: Fixes the 26 service methods using recoverCatching + parseErrorBodyOrNull (cipher create/update/archive/unarchive, send CRUD, account operations, identity operations, folder update, cipher import). The 80 service methods without recoverCatching still show a generic error but preserve the exception via "Share Error Details" — to be addressed in a follow-up.

📸 Screenshots

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/6640 **Author:** [@SaintPatrck](https://github.com/SaintPatrck) **Created:** 3/11/2026 **Status:** ✅ Merged **Merged:** 3/11/2026 **Merged by:** [@SaintPatrck](https://github.com/SaintPatrck) **Base:** `release/2026.3-rc48` ← **Head:** `release/2026.3-rc48_cp-PM-333394` --- ### 📝 Commits (1) - [`4d13974`](https://github.com/bitwarden/android/commit/4d13974aca88e431439c4ddf5677d3724f99f06f) 🍒[PM-33394] fix: Propagate CookieRedirectException error message through existing Http error pipeline ### 📊 Changes **3 files changed** (+187 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `network/src/main/kotlin/com/bitwarden/network/model/BitwardenError.kt` (+21 -0) ➕ `network/src/test/kotlin/com/bitwarden/network/model/BitwardenErrorTest.kt` (+67 -0) ➕ `network/src/test/kotlin/com/bitwarden/network/util/ExceptionExtensionsTest.kt` (+99 -0) </details> ### 📄 Description ## 🎟️ Tracking https://bitwarden.atlassian.net/browse/PM-33394 Cherry-picked from #6639 ## 📔 Objective When SSO cookies expire in a load-balanced environment, API actions trigger a `CookieRedirectException`. After the app completes the "Sync with browser" re-authentication flow, a **generic error** was shown ("We were unable to process your request") instead of the exception's descriptive message ("Your request was interrupted because the app needed to re-authenticate. Please try again."). **Root cause:** `CookieRedirectException` extends `IOException`, so `toBitwardenError()` classified it as `BitwardenError.Network`. The `parseErrorBodyOrNull()` function only handles `BitwardenError.Http`, returning `null` for network errors — causing the message to be lost. **Fix:** Updated `toBitwardenError()` to intercept `CookieRedirectException` before the generic `IOException` check (since it's a subclass). Synthesizes a `BitwardenError.Http` with a 400 response and JSON body containing the exception message, allowing it to flow through the existing `parseErrorBodyOrNull` pipeline with zero changes to downstream code. **Scope:** Fixes the 26 service methods using `recoverCatching` + `parseErrorBodyOrNull` (cipher create/update/archive/unarchive, send CRUD, account operations, identity operations, folder update, cipher import). The 80 service methods without `recoverCatching` still show a generic error but preserve the exception via "Share Error Details" — to be addressed in a follow-up. ## 📸 Screenshots <video src="https://github.com/user-attachments/assets/d0628145-699f-4696-9d4e-80f6c078b89c" /> --- <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 2026-05-01 20:49:46 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#54958