Skip to content

[PM-39840] fix: Use dedicated OkHttpClient for fill-assist to prevent load-balancer prompt#7131

Merged
aj-rosado merged 5 commits into
mainfrom
PM-39840/fix-fill-assist-trigger-load-balancer
Jul 3, 2026
Merged

[PM-39840] fix: Use dedicated OkHttpClient for fill-assist to prevent load-balancer prompt#7131
aj-rosado merged 5 commits into
mainfrom
PM-39840/fix-fill-assist-trigger-load-balancer

Conversation

@aj-rosado

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-39840

📔 Objective

The fill-assist service fetches targeting rules from https://github.com/bitwarden/map-the-web/releases/latest/download/manifest.json. GitHub's CDN responds with an HTTP 302 redirect for content delivery.

The CookieInterceptor, present on the shared unauthenticated OkHttpClient, treats any 302 response as a Bitwarden load-balancer auth redirect. It calls cookieProvider.acquireCookies(hostname) as a side effect before throwing CookieRedirectException, which navigates the app to the "Sync with Browser" load-balancer screen — even though the 302 was a legitimate CDN redirect unrelated to Bitwarden authentication.

This affected users on self-hosted environments without a load balancer (USQA, USDEV, and similar), blocking sign-in and vault unlock.

Fix: Introduce a dedicated fillAssistOkHttpClient in RetrofitsImpl that keeps headers and SSL certificate validation but excludes CookieInterceptor and PermissionInterceptor. fillAssistRetrofit now uses this client so OkHttp's default redirect handling processes the CDN 302 correctly.

@aj-rosado aj-rosado added the ai-review Request a Claude code review label Jul 1, 2026
@github-actions github-actions Bot added app:password-manager Bitwarden Password Manager app context app:authenticator Bitwarden Authenticator app context t:bug Change Type - Bug labels Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the fix that routes fillAssistRetrofit through a new externalOkHttpClient in RetrofitsImpl, isolating external CDN traffic from CookieInterceptor. The change correctly targets the root cause: CookieInterceptor treats every 302 as a Bitwarden load-balancer auth redirect (CookieInterceptor.kt:72-84), which misfires on GitHub's legitimate CDN 302. The new client preserves headers and SSL certificate validation while dropping only the cookie behavior, and permissionInterceptor is retained so the local-network-access gate still applies. Added test asserts the correct interceptor set is invoked.

Code Review Details

No blocking findings.

  • Security: SSL certificate validation (configureSsl) is retained on the external client, so no trust-boundary regression.
  • Correctness: The interceptor set (headers, baseUrl, logging, permission; no cookie) matches the added test and the stated intent.
  • The three remaining unresolved threads (make generic, rename to createExternalRetrofit, plural fix) are all marked outdated and were addressed by later commits.

Minor note (not blocking): the PR description states the fix excludes PermissionInterceptor, but the final code retains it (correctly re-added per earlier review feedback). Consider updating the description wording for accuracy.

Comment thread network/src/main/kotlin/com/bitwarden/network/retrofit/RetrofitsImpl.kt Outdated
Comment thread network/src/main/kotlin/com/bitwarden/network/retrofit/RetrofitsImpl.kt Outdated
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.76%. Comparing base (b01067f) to head (4037767).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7131      +/-   ##
==========================================
+ Coverage   86.19%   86.76%   +0.57%     
==========================================
  Files        1032      868     -164     
  Lines       67112    63939    -3173     
  Branches     9443     9577     +134     
==========================================
- Hits        57848    55479    -2369     
+ Misses       6001     5017     -984     
- Partials     3263     3443     +180     
Flag Coverage Δ
app-data 17.60% <0.00%> (-0.30%) ⬇️
app-ui-auth-tools 18.77% <0.00%> (-0.38%) ⬇️
app-ui-platform 16.48% <0.00%> (-0.61%) ⬇️
app-ui-vault 27.51% <0.00%> (-0.72%) ⬇️
authenticator 6.18% <0.00%> (+0.02%) ⬆️
lib-core-network-bridge 4.09% <100.00%> (+0.04%) ⬆️
lib-data-ui 1.14% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aj-rosado
aj-rosado marked this pull request as ready for review July 2, 2026 08:58
@aj-rosado
aj-rosado requested review from a team and david-livefront as code owners July 2, 2026 08:58

// Fill-assist might use HTTP 302 redirects for content delivery.
// CookieInterceptor treats all 302s as auth redirects.
private val fillAssistOkHttpClient: OkHttpClient = OkHttpClient.Builder()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this more generic? I can envision a future API that also need to avoid the Cookie Interceptor.

Something that makes it more reusable and not explicitly tied to the FillAssist feature.

)
.build()

private fun createFillAssistRetrofit(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this function to createExternalRetrofit to match the OkHttpClient too.

@aj-rosado
aj-rosado requested a review from david-livefront July 2, 2026 19:05
// For requests to external (non-Bitwarden) URLs. CookieInterceptor must be excluded because
// it treats all 302s as Bitwarden load-balancer auth redirects, which is only correct for
// Bitwarden's own infrastructure.
// Bitwarden own infrastructure.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have an s, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@aj-rosado
aj-rosado requested a review from david-livefront July 2, 2026 20:15
@aj-rosado
aj-rosado added this pull request to the merge queue Jul 3, 2026
Merged via the queue into main with commit 200794c Jul 3, 2026
29 checks passed
@aj-rosado
aj-rosado deleted the PM-39840/fix-fill-assist-trigger-load-balancer branch July 3, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review app:authenticator Bitwarden Authenticator app context app:password-manager Bitwarden Password Manager app context t:bug Change Type - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants