fix(ollama): try every browser before giving up on cookie import - #430
fix(ollama): try every browser before giving up on cookie import#430leoarayas wants to merge 1 commit into
Conversation
Auto/Web cookie import stopped at the first installed browser that returned any cookies for ollama.com, even when those cookies were stale/irrelevant (e.g. a consent or analytics cookie left over from a one-off visit) and carried no recognized session cookie. That starved out a later browser (often the one actually signed in) and surfaced "No cookies available for web API" even with a valid, logged-in session sitting on disk. Walk every detected browser and keep going until one yields a header containing a recognized Ollama session cookie, instead of stopping at the first non-empty result. Extracted the selection logic into a small pure helper with a focused regression test reproducing the exact scenario (irrelevant-only cookies on one browser, real session on the next). Fixes nesszer#426 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L23pzyCfMvfbMQwnHXmKCp
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughOllama browser cookie resolution now scans all detected browsers and selects the first cookie set with a recognized session cookie. Tests cover skipping irrelevant cookie sets and returning no header when no session cookie is found. ChangesOllama cookie resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Ollama Web cookie import now continues to later browsers when earlier cookie sets lack a recognized session, allowing valid sessions to supply usage data. No current merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The pull request fixes browser iteration when an earlier browser has irrelevant Ollama cookies. However, issue Resolution Update or verify cookie_applies_to_ollama_url and ollama_cookie_header_for_url so valid Ollama session cookies are accepted with their real browser domain and path attributes. Add a regression test for that cookie-matching case, in addition to the multi-browser test.
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
Fixes #426.
Auto/Web cookie import for Ollama used
browser_cookies_for_domain, which stops at the first installed browser that returns any cookies forollama.com— even when those cookies are stale/irrelevant (e.g. an analytics or consent cookie left over from a one-off visit in Chrome/Edge) and carry no recognized session cookie. That starves out a later browser (often the one actually signed in, e.g. Brave) and the fetch fails withNo cookies available for web API, even though a valid, logged-in session is sitting right there on disk.Fix
resolve_browser_cookie_headernow walks every detected browser and keeps going until one yields a header containing a recognized Ollama session cookie, instead of stopping at the first non-empty result. The selection logic is extracted into a small pure helper (first_recognized_cookie_header) so it's testable without real browser I/O.Verified
ollama.comcookies, Brave held the real__Secure-session, and the old code returnedNoCookieswhile stopping at Chrome.codexbar diagnose -p ollamareturns real, cookie-scraped usage data end-to-end.Test plan
All pass.
🤖 Generated with Claude Code
https://claude.ai/code/session_01L23pzyCfMvfbMQwnHXmKCp
Summary by CodeRabbit