Skip to content

fix(zhihu): stop question command failing on unused detail fetch#606

Merged
jackwener merged 2 commits intojackwener:mainfrom
Astro-Han:fix/zhihu-question
Mar 30, 2026
Merged

fix(zhihu): stop question command failing on unused detail fetch#606
jackwener merged 2 commits intojackwener:mainfrom
Astro-Han:fix/zhihu-question

Conversation

@Astro-Han
Copy link
Copy Markdown
Contributor

Description

Fix zhihu question so it no longer fails when an unused question detail request returns 403.

The adapter was fetching both question detail and answers in parallel, but only the answers response was actually used in the CLI output. In a real logged-in Browser Bridge session, the detail request now returns 403 with Zhihu error code 10003, which caused the whole command to surface a misleading AuthRequiredError even though the answers request succeeded.

This change removes the unused detail request and keeps the command focused on the answers data it already renders.

Related issue:

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Documentation (if adding/modifying an adapter)

  • Added doc page under docs/adapters/ (if new adapter)
  • Updated docs/adapters/index.md table (if new adapter)
  • Updated sidebar in docs/.vitepress/config.mts (if new adapter)
  • Updated README.md / README.zh-CN.md when command discoverability changed
  • Used positional args for the command's primary subject unless a named flag is clearly better
  • Normalized expected adapter failures to CliError subclasses instead of raw Error

Screenshots / Output

Before the fix, this returned:

node dist/main.js zhihu question 2021881398772981878 --limit 3 -f json
🔒 Not logged in to www.zhihu.com
→ Please open Chrome and log in to https://www.zhihu.com

After the fix, the same command returns answer rows successfully.

Checks run:

  • npx vitest run src/clis/zhihu/question.test.ts --project adapter
  • npm run test:adapter
  • npm test
  • npm run build
  • npx tsx src/main.ts zhihu question 2021881398772981878 --limit 3 -f json
  • node dist/main.js zhihu question 2021881398772981878 --limit 3 -f json

@Gogoworks
Copy link
Copy Markdown

Tested the fix branch locally — confirmed working.

$ node /tmp/opencli-test/dist/main.js zhihu question 2021881398772981878 --limit 5 -f json

Returns 5 answers with correct author, votes, and content. No login error.

Previously the same command on v1.5.6 gave 🔒 Not logged in to www.zhihu.com.

Env: macOS Darwin 25.4.0 / Node v22.22.1 / Extension v1.5.5 / Chrome Profile with active Zhihu session.

Thanks @Astro-Han for the quick turnaround!

@Astro-Han Astro-Han marked this pull request as ready for review March 30, 2026 13:44
@jackwener jackwener merged commit 59d41f2 into jackwener:main Mar 30, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants