← Back to AI Insights
Gemini Executive Synthesis

Inconsistent authentication handling for `opencli`'s Zhihu adapter, specifically for the `question` command.

Technical Positioning
Ensuring consistent and reliable authenticated access to web services via a unified CLI, enabling AI agents to discover, learn, and execute tools seamlessly.
SaaS Insight & Market Implications
This issue details a critical authentication inconsistency within `opencli`'s Zhihu adapter. While some commands function correctly, the `question` command fails due to improper cookie handling during `page.evaluate()` calls. The root cause is a missing navigation step to establish the correct domain context for cookie inclusion. This exposes a vulnerability in `opencli`'s promise of seamless web interaction, as it requires specific, non-obvious workarounds for different commands within the same service. Market implication: for a "universal CLI Hub" targeting AI agents, such inconsistencies create brittle integrations, increase development overhead for tool adapters, and undermine the reliability required for autonomous agent operations. Robust, standardized session management across all commands is paramount.
Proprietary Technical Taxonomy
Browser Bridge extension opencli zhihu question Not logged in to www.zhihu.com valid session page.evaluate() fetch(..., {credentials: 'include'}) browser context cookies

Raw Developer Origin & Technical Request

Source Icon GitHub Issue Mar 30, 2026
Repo: jackwener/opencli
zhihu question command fails with 'Not logged in' despite valid session

## Bug Description

`opencli zhihu question ` always fails with `🔒 Not logged in to www.zhihu.com`, even when the user is logged in to Zhihu in the browser profile where the Browser Bridge extension is installed.

Other Zhihu commands (e.g. `zhihu search`) work correctly with the same login session.

## Environment

- opencli: v1.5.6
- Extension: v1.5.5
- OS: macOS (Darwin 25.4.0)
- Node: v22.22.1

## Steps to Reproduce

1. Install Browser Bridge extension in a Chrome profile that is logged in to zhihu.com
2. Verify `opencli zhihu search "any query"` works (it does)
3. Run `opencli zhihu question 2021881398772981878`
4. Result: `🔒 Not logged in to www.zhihu.com`

## Root Cause

In `src/clis/zhihu/question.ts`, the command calls `page.evaluate()` with `fetch(..., {credentials: 'include'})` directly, without first navigating to the Zhihu domain. Since the browser context is not on `www.zhihu.com`, cookies are not attached to the fetch request, and the Zhihu API returns an auth error.

In contrast, `src/clis/zhihu/search.yaml` includes a `navigate: zhihu.com` step before the evaluate, which establishes the correct domain context for cookies to be sent.

## Suggested Fix

Add a navigation step in `question.ts` before the `page.evaluate()` call:

```typescript
await page.goto('zhihu.com&
```

This matches the pattern used in `search.yaml` and should allow `credentials: 'include'` to work correctly.

Developer Debate & Comments

Astro-Han • Mar 30, 2026
Checked the current repo state and the suggested root cause here looks outdated. `zhihu question` does **not** rely only on `src/clis/zhihu/question.ts` for domain navigation anymore. Since commit `a228758` on March 21, 2026, browser commands with `Strategy.COOKIE` / `Strategy.HEADER` are pre-navigated in `src/execution.ts` via `resolvePreNav()` before the adapter `func` runs. `zhihu/question.ts` already has: - `domain: 'www.zhihu.com'` - `strategy: Strategy.COOKIE` So in current `main`, and also in the local `v1.5.5` tag I checked, execution should already pre-navigate to `https://www.zhihu.com` before the `page.evaluate(...fetch(..., { credentials: 'include' }))` call. A few things here do not line up yet: 1. This repo currently declares `1.5.5` in `package.json`, and the latest local tag is also `v1.5.5`. 2. The issue reports `opencli v1.5.6`, which I cannot correlate to a tag in the repo state I checked. 3. Because of that, I am not confident the failure is caused by a missing...
Gogoworks • Mar 30, 2026
Thanks for the thorough review @Astro-Han. You're right — my root cause analysis was incorrect. After further testing, the real issue is that the **Browser Bridge extension intermittently disconnects**, and the error message differs depending on the code path: - **With `-v` flag**: correctly shows `🔌 Browser Bridge not connected` - **Without `-v` flag**: shows `🔒 Not logged in to www.zhihu.com` (misleading) When the extension IS connected, `zhihu search` and `twitter profile` both work fine. When it disconnects (which seems to happen after Chrome idles or restarts), ALL browser-dependent commands fail — but `zhihu question` surfaces the error as "Not logged in" instead of "Bridge not connected". So there are actually two separate issues: 1. **Misleading error message**: `zhihu question` (and possibly other `Strategy.COOKIE` commands) throws `AuthRequiredError` when the bridge is disconnected, masking the real connectivity problem. The non-verbose path doesn't distinguish between "...
Gogoworks • Mar 30, 2026
Update: After the daemon restarted, I can confirm the issue is specific to `zhihu question`, NOT a general bridge connectivity problem. - `opencli bilibili hot` ✅ works - `opencli zhihu search "test"` ✅ works - `opencli zhihu question 2021881398772981878` ❌ `Not logged in` All tested in the same session with the same bridge connection. The earlier "Bridge not connected" errors were due to a daemon restart (PID changed from 80670 → 43950), which is now resolved. So the bug is indeed isolated to `zhihu question`. The pre-navigation via `resolvePreNav()` may not be working correctly for this specific command, or the `page.evaluate()` fetch context loses the cookie after pre-nav. Happy to test any debug build if that helps. ``` $ opencli zhihu question 2021881398772981878 --limit 5 -v 🔒 Not logged in to www.zhihu.com → Please open Chrome and log in to https://www.zhihu.com ```
Astro-Han • Mar 30, 2026
Thanks for the additional verification. We have reproduced the reasoning gap on our side and the current diagnosis is now much clearer. What we have confirmed: - `v1.5.6` matches the current repository code for `src/clis/zhihu/question.ts` and the browser pre-navigation path in `src/execution.ts` - so this is not a release mismatch issue - `zhihu question` currently collapses every non-OK response into `AuthRequiredError`, which is why different failures surface as the same misleading "Not logged in" message - the problem is very likely in the adapter path itself, not in the generic Browser Bridge pre-navigation layer At this point, this no longer looks like "just add one more goto()". It looks more like the current `question` adapter is relying on a brittle request path and has incorrect error classification. We'll take this issue and work on a proper fix. Planned direction: 1. fix the error classification so auth failure, anti-bot/risk-control, and unexpected API errors are not...
Astro-Han • Mar 30, 2026
A draft fix is up here: - What changed: - `zhihu question` was fetching both question detail and answers in parallel - only the answers response was actually used in the current CLI output - the extra question detail request now returns `403` in a real logged-in Browser Bridge session, which caused the whole command to surface a misleading login failure - the fix removes that unused detail request and keeps the command focused on the answers payload it already renders I also verified the fix locally against a real Browser Bridge session, both through `tsx` and the built `dist/main.js` path. Could you please test the branch / PR build with your original reproduction steps and confirm whether it resolves the issue on your side? Suggested check: ```bash opencli zhihu question 2021881398772981878 --limit 5 -f json ``` If you still see a failure, please paste the exact output and whether it happens with `-v` as well.

Adjacent Repository Pain Points

Other highly discussed features and pain points extracted from jackwener/opencli.

Extracted Positioning
Browser extension conflict preventing `chrome.debugger.attach()` in OpenCLI
Reliable browser automation and web interaction via CLI
Top Replies
haoyueb2 • Mar 22, 2026
macos也有一样的错
Astro-Han • Mar 22, 2026
**根因分析** 当用户安装了"新标签页覆盖"类扩展(如 iTab、Momentum 等)时,Chrome 会把新窗口的 `about:blank` 替换为 `chrome-extension://` 页面。 问题出在 `extension/src/background.ts` 的 `resolveTabI...
jackwener • Mar 22, 2026
记得更新浏览器插件和版本
Extracted Positioning
Native support for VK (VKontakte) as a built-in OpenCLI command
Universal CLI Hub capable of bypassing anti-bot protections for major web services
Top Replies
flobo3 • Mar 23, 2026
Just to add some context and numbers to back this up: - According to recent stats, VK is the absolute leader in content publications in Russia: https://www.statista.com/statistics/284447/social-med...
Astro-Han • Mar 24, 2026
+1 on this. VK's reliance on dynamic CSRF tokens and internal AJAX endpoints (`al_wall.php`) is a strong fit for opencli's browser session approach — exactly the kind of site where traditional scra...
flobo3 • Mar 24, 2026
Hey @jackwener and @Astro-Han! Thanks for the tips on using `opencli record`. It turned out VK uses a JSON Hijacking protection (prepends `
Extracted Positioning
Authentication persistence and session management for `opencli` when interacting with web services like WeRead.
Providing seamless, authenticated CLI access to web services for both human users and AI agents. The goal is a "universal CLI Hub" where tools are discovered and executed seamlessly.
Top Replies
Astro-Han • Mar 30, 2026
收到 bug 反馈,我先尝试复现。
Astro-Han • Mar 30, 2026
继续排查后,结论更新一下: 目前看,这个问题主要集中在 `MP_WXS_*` 这类公众号条目,不像是单纯的登录失效。 现在 `weread shelf` 还能显示,是因为私有 API 失效后会回退到网页本地缓存;但 `weread book` 打...
haoyan-yam • Mar 30, 2026
> 继续排查后,结论更新一下: > > 目前看,这个问题主要集中在 `MP_WXS_*` 这类公众号条目,不像是单纯的登录失效。 > > 现在 `weread shelf` 还能显示,是因为私有 API 失效后会回退到网页本地缓存;但 `weread...
Extracted Positioning
Monorepo support for OpenCLI plugin installation and discovery
Enterprise-grade tool integration for internal automation teams and AI agents
Extracted Positioning
Feature request for a Baidu Tieba adapter for `opencli`.
Expanding `opencli`'s reach to major Chinese community platforms, enhancing its claim as a "universal CLI Hub" for AI agents to discover and execute tools across diverse web services.

Engagement Signals

5
Replies
open
Issue Status

Cross-Market Term Frequency

Quantifies the cross-market adoption of foundational terms like cookies and Browser Bridge extension by tracking occurrence frequency across active SaaS architectures and enterprise developer debates.