{"record":{"id":"3048149012e58011","repo":"jackwener/OpenCLI","slug":"zhihu-user","errorCode":null,"errorMessage":"zhihu user","messagePattern":"zhihu user","errorType":"error_code","errorClass":"EmptyResultError","httpStatus":404,"severity":"warning","filePath":"clis/zhihu/user.js","lineNumber":40,"sourceCode":"        const apiUrl = `https://www.zhihu.com/api/v4/members/${encodeURIComponent(slug)}?include=${encodeURIComponent(INCLUDE)}`;\n        const data = unwrapEvaluateResult(await page.evaluate(`\n      (async () => {\n        try {\n          const r = await fetch(${JSON.stringify(apiUrl)}, { credentials: 'include' });\n          if (!r.ok) return { __httpError: r.status };\n          return await r.json();\n        } catch (err) {\n          return { __fetchError: err?.message || String(err) };\n        }\n      })()\n    `));\n        if (!data || typeof data !== 'object' || Array.isArray(data) || data.__httpError || data.__fetchError) {\n            const status = data?.__httpError;\n            if (status === 401 || status === 403) {\n                throw new AuthRequiredError('www.zhihu.com', 'Failed to fetch Zhihu user profile');\n            }\n            if (status === 404) {\n                throw new EmptyResultError('zhihu user', `No Zhihu user was found for ${slug}.`);\n            }\n            throw new CommandExecutionError(status ? `Zhihu user request failed (HTTP ${status})` : 'Zhihu user request failed', data?.__fetchError ? String(data.__fetchError) : 'Try again later or rerun with -v');\n        }\n        if (!data.url_token || !data.id || !data.name) {\n            throw new CommandExecutionError('Zhihu user response missing identity fields', 'Zhihu may have changed its API shape');\n        }\n        return [{\n            url_token: String(data.url_token || ''),\n            name: String(data.name || ''),\n            headline: String(data.headline || ''),\n            followers: data.follower_count ?? 0,\n            following: data.following_count ?? 0,\n            answers: data.answer_count ?? 0,\n            articles: data.articles_count ?? 0,\n            voteup: data.voteup_count ?? 0,\n            url: data.url_token ? `https://www.zhihu.com/people/${data.url_token}` : '',\n        }];\n    },","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/zhihu/user.js#L22-L58","documentation":"EmptyResultError with resource 'zhihu user' is thrown when the in-page fetch returns HTTP 404 — i.e. no Zhihu user exists for the given slug. It is the 'not found' branch of the user profile command's error handling.","triggerScenarios":"Requesting a profile whose url_token does not exist: a typo in the slug, a user who renamed their url_token, a deactivated/deleted account, or passing a display name instead of the url_token that happens to 404.","commonSituations":"Hardcoded slugs that broke after the user renamed their profile; scraping historical usernames; copying an incomplete URL fragment as the slug.","solutions":["Verify the url_token in the browser by visiting https://www.zhihu.com/people/<slug>","Re-resolve the user's current url_token (it can change after renames)","Check for typos or truncation in the slug argument","Confirm the account still exists and wasn't deactivated"],"exampleFix":"// before\nnode cli.js zhihu user wen-jie-1647\n// after\nnode cli.js zhihu user wen-jie-16-47","handlingStrategy":"validation","validationCode":"// before calling, sanity-check the slug format and existence in the browser\nconst slugOk = typeof slug === 'string' && /^[A-Za-z0-9_-]+$/.test(slug);\nif (!slugOk) throw new Error('Invalid url_token format: ' + slug);\n// existence check: fetch https://www.zhihu.com/people/<slug> and expect 200","typeGuard":"const isPlausibleSlug = (s) => typeof s === 'string' && s.length > 0 && /^[A-Za-z0-9_-]+$/.test(s);","tryCatchPattern":"try {\n  const user = await fetchZhihuUser(slug);\n} catch (e) {\n  if (e instanceof EmptyResultError) {\n    console.warn(`No Zhihu user for ${slug}; skipping`);\n    return null;\n  }\n  throw e;\n}","preventionTips":["Verify url_tokens by opening https://www.zhihu.com/people/<slug> before automation","Re-resolve slugs periodically — users can rename their url_token","Treat EmptyResultError as 'skip this user' in batch jobs","Don't derive slugs from display names"],"tags":["not-found","zhihu","slug"],"backgroundTag":"resource-not-found-404","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}