{"record":{"id":"901617f0b8849901","repo":"jackwener/OpenCLI","slug":"zhihu-search","errorCode":null,"errorMessage":"zhihu search","messagePattern":"zhihu search","errorType":"error_code","errorClass":"EmptyResultError","httpStatus":null,"severity":"info","filePath":"clis/zhihu/search.js","lineNumber":184,"sourceCode":"                if (type !== 'all' && normalized.row.type !== type) continue;\n                if (seen.has(normalized.key)) continue;\n                seen.add(normalized.key);\n                results.push(normalized.row);\n                if (results.length >= resultLimit) break;\n            }\n            if (results.length >= resultLimit) break;\n            if (data.paging?.is_end) break;\n            const next = normalizeSearchUrl(data.paging?.next);\n            if (!next) {\n                throw new CommandExecutionError('Zhihu search pagination returned malformed next URL');\n            }\n            if (visited.has(next)) {\n                throw new CommandExecutionError('Zhihu search pagination returned a repeated next URL');\n            }\n            url = next;\n        }\n        if (results.length === 0) {\n            throw new EmptyResultError('zhihu search', `No ${type === 'all' ? '' : `${type} `}results found for \"${query}\"`);\n        }\n        return results.map((row, i) => {\n            return {\n                rank: i + 1,\n                ...row,\n            };\n        });\n    },\n});\n\nexport const __test__ = {\n    stripHtml,\n    itemKey,\n    itemUrl,\n    normalizeSearchUrl,\n    parseLimit,\n    requireQuery,\n    requireType,","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/zhihu/search.js#L166-L202","documentation":"This is an EmptyResultError thrown when a completed zhihu search produced zero rows for the given query and type filter. It is the library's way of distinguishing 'the command ran fine but found nothing' from command failures, using the type and query in the message (e.g. 'No answer results found for \"x\"').","triggerScenarios":"Any searchZhihu invocation where the API returns pages successfully but data.data contains no items matching the query/type, so results.length === 0 after pagination ends.","commonSituations":"Misspelled or overly specific query, wrong --type filter (e.g. article when only answers exist), query matching deleted/private content, region or login state causing Zhihu to return empty results.","solutions":["Retry with a broader or corrected query string","Drop or change the --type filter (use 'all')","Check the query on zhihu.com in a browser to confirm results exist","If content is login-gated, ensure the browser session used by the CLI is authenticated"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Can't fully predict; sanity-check the query is non-empty before calling\nif (!query.trim()) throw new Error('query required before zhihu search');","typeGuard":null,"tryCatchPattern":"try {\n  const results = await zhihuSearch(query, { type });\n} catch (err) {\n  if (err instanceof EmptyResultError || /No .* results found/.test(err.message)) {\n    console.log(`No results for \"${query}\" (${type}); try a broader query or type 'all'.`);\n    return [];\n  }\n  throw err;\n}","preventionTips":["Catch EmptyResultError separately from other errors and treat it as an empty set","Verify the query has matches on zhihu.com before assuming a bug","Default to type 'all' when unsure of content type","Check authentication state if Zhihu gates results behind login"],"tags":["zhihu","search","empty-result"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}