Skip to content

[PM-39812] fix: Apply SSO cookie request handlers to HTTPService download functions - #2848

Merged
fedemkr merged 3 commits into
mainfrom
PM-39812/sso-cookies-fix-for-attachments
Jul 17, 2026
Merged

[PM-39812] fix: Apply SSO cookie request handlers to HTTPService download functions#2848
fedemkr merged 3 commits into
mainfrom
PM-39812/sso-cookies-fix-for-attachments

Conversation

@fedemkr

@fedemkr fedemkr commented Jul 1, 2026

Copy link
Copy Markdown
Member

🎟️ Tracking

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

📔 Objective

The download(from:) and download(filename:) methods in HTTPService bypassed
the request handler pipeline entirely, meaning SSOCookieVendorRequestHandler never
injected load-balancer cookies into download requests. On servers configured with SSO
cookie vendor bootstrap, this caused attachment downloads to throw errors.

Fix: Both download methods now call applyRequestHandlers(to:) before passing the
request to the underlying client, mirroring what send(_:) already did. A failable
HTTPRequest.init?(from: URLRequest) bridges the URLRequest-based download API into
the HTTPRequest-based handler pipeline.

Note

The response handler was not added here as that handles HTTPResponse instead of URL on the download functions. We could potentially add handling for that as well but requires more complex changes. So for now the request handler has been added which adds the cookie if it's available as we think it's an edge case that just at the moment of downloading an attachment the cookie expires.

…load functions

The download(from:) and download(filename:) methods bypassed the request
handler pipeline entirely, so SSOCookieVendorRequestHandler never injected
load-balancer cookies into download requests. This caused attachment
downloads to fail on servers with SSO cookie vendor bootstrap configured.
@fedemkr fedemkr 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
@fedemkr
fedemkr marked this pull request as ready for review July 1, 2026 19:54
@fedemkr
fedemkr requested review from a team and matt-livefront as code owners July 1, 2026 19:54
@fedemkr fedemkr added the enhancement New feature or request label 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 routing HTTPService.download(from:) and download(filename:) through the request handler pipeline so SSOCookieVendorRequestHandler injects load-balancer cookies into download requests. The new HTTPRequest.init?(from:) bridge, the applyRequestHandlers(to:) helper, and the header round-trip were verified for correctness. Confirmed both production call sites (apiUnauthenticatedService, fillAssistService) are token-provider-free, so no unintended Authorization header is injected. Test refactor extracting shared response handlers into Support files and updated coverage are appropriate.

Code Review Details

No findings. The header round-trip is safe (handlers only add to headers seeded from the original request), the nil URL guard is covered by tests, and the omission of response handlers is intentional and documented in the PR description.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.00%. Comparing base (dae7094) to head (d3fddbd).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
Networking/Sources/Networking/HTTPService.swift 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2848      +/-   ##
==========================================
- Coverage   81.25%   79.00%   -2.26%     
==========================================
  Files        1028     1151     +123     
  Lines       66164    73508    +7344     
==========================================
+ Hits        53761    58073    +4312     
- Misses      12403    15435    +3032     

☔ 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.

@matt-livefront matt-livefront left a comment

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.

These changes look good, looks like there's one test failure though.

fedemkr added 2 commits July 16, 2026 18:20
… full URLRequest

Download requests now pass through DefaultHeadersRequestHandler, which adds
headers (User-Agent, Device-Type, etc.), so strict URLRequest equality no
longer holds even though the URL itself is unchanged.
@fedemkr
fedemkr requested a review from matt-livefront July 17, 2026 15:47
@fedemkr
fedemkr enabled auto-merge (squash) July 17, 2026 15:48
@fedemkr
fedemkr merged commit 173e3c6 into main Jul 17, 2026
15 checks passed
@fedemkr
fedemkr deleted the PM-39812/sso-cookies-fix-for-attachments branch July 17, 2026 16:32
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 enhancement New feature or request t:bug Change Type - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants