-
Notifications
You must be signed in to change notification settings - Fork 927
PM-28053: Ensure any exception thrown during re-auth is an IO exception #6175
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
Conversation
|
Claude finished @david-livefront's task —— View job Code Review CompleteOverall Assessment: REQUEST CHANGES Critical Issues:
See inline comments for detailed feedback and code suggestions. Review SummaryThis PR successfully addresses the core issue of ensuring Retrofit can handle all exceptions by converting them to
Findings: Finding 1: ❌ Incomplete test coverage for The new extension function at lines 128-132 of
See inline comment on Finding 2: Per
See inline comment on Finding 3: 💭 Test organization suggestion Consider adding a dedicated nested test class (e.g., Positive Observations
Action ItemsRequired:
Optional: |
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6175 +/- ##
==========================================
+ Coverage 84.97% 84.99% +0.02%
==========================================
Files 735 723 -12
Lines 53087 52858 -229
Branches 7678 7678
==========================================
- Hits 45113 44929 -184
+ Misses 5291 5246 -45
Partials 2683 2683 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
network/src/main/kotlin/com/bitwarden/network/interceptor/AuthTokenManager.kt
Show resolved
Hide resolved
08a6b05 to
1c00c1a
Compare
| private fun Throwable.toIoException(): IOException = | ||
| when (this) { | ||
| is IOException -> this | ||
| else -> IOException(this) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Missing test coverage and documentation
Details
This new extension function needs:
-
Direct unit tests - Codecov reports 60% patch coverage. Add tests for:
IOExceptionpassthrough case (line 130)- Non-
IOExceptionwrapping case (line 131)
-
KDoc documentation - Per project guidelines, explain:
- Why this conversion is needed (Retrofit compatibility)
- Behavior for each case
Suggested tests:
@Nested
inner class ToIoExceptionExtension {
@Test
fun `toIoException returns IOException unchanged`() {
val original = IOException("test error")
val result = original.toIoException()
assertSame(original, result)
}
@Test
fun `toIoException wraps non-IOException in IOException`() {
val original = IllegalStateException("test error")
val result = original.toIoException()
assertTrue(result is IOException)
assertSame(original, result.cause)
}
}Suggested documentation:
/**
* Converts this [Throwable] to an [IOException] for Retrofit compatibility.
*
* Retrofit's error handling requires [IOException] instances. This extension ensures
* all exceptions thrown during token refresh are properly wrapped.
*/
network/src/main/kotlin/com/bitwarden/network/interceptor/AuthTokenManager.kt
Show resolved
Hide resolved
network/src/test/kotlin/com/bitwarden/network/interceptor/AuthTokenManagerTest.kt
Show resolved
Hide resolved
|
Thanks @SaintPatrck |

🎟️ Tracking
PM-28053
📔 Objective
This PR updates the
AuthTokenManagerto ensure that all exceptions throw are handled by Retrofit.The main issue here was that
HttpExceptionscould be throw from network errors and Retrofit can only handleIOExceptions.⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes