{"record":{"id":"fa9c5a687a7a0ab4","repo":"jackwener/OpenCLI","slug":"not-found-fa9c5a","errorCode":"NOT_FOUND","errorMessage":"No Gitee repository search results found","messagePattern":"No Gitee repository search results found","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"warning","filePath":"clis/gitee/search.js","lineNumber":107,"sourceCode":"        apiUrl.searchParams.set('size', String(fetchSize));\n        await page.goto(searchUrl);\n        await page.wait(2);\n        const response = await fetch(apiUrl.toString(), {\n            headers: {\n                Accept: 'application/json',\n                'User-Agent': 'Mozilla/5.0',\n                Referer: searchUrl,\n            },\n        });\n        if (!response.ok) {\n            throw new CliError('REQUEST_FAILED', `Failed to request Gitee search API: ${response.status}`, 'Try again later or verify network access to so.gitee.com');\n        }\n        const payload = await response.json();\n        const payloadRecord = asRecord(payload);\n        const hitsRecord = asRecord(payloadRecord?.hits);\n        const rawRows = Array.isArray(hitsRecord?.hits) ? hitsRecord.hits : [];\n        if (rawRows.length === 0) {\n            throw new CliError('NOT_FOUND', 'No Gitee repository search results found', 'Try a different keyword or check whether Gitee search API changed');\n        }\n        const seen = new Set();\n        const rows = [];\n        for (let i = 0; i < rawRows.length && rows.length < limit; i++) {\n            const row = asRecord(rawRows[i]);\n            const fields = asRecord(row?.fields);\n            if (!fields)\n                continue;\n            const name = normalizeText(getFirstText(fields.title));\n            const repoUrl = normalizeUrl(getFirstText(fields.url));\n            if (!name || !repoUrl)\n                continue;\n            if (seen.has(repoUrl))\n                continue;\n            seen.add(repoUrl);\n            rows.push({\n                rank: rows.length + 1,\n                name,","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gitee/search.js#L89-L125","documentation":"CliError with code NOT_FOUND thrown when the Gitee search API responds ok but the payload contains no hits — payload.hits.hits is missing or an empty array. The library distinguishes 'request failed' from 'request succeeded but zero results' with this error.","triggerScenarios":"Calling gitee search with a keyword that matches no repositories; Gitee returning an empty or restructured payload (e.g. hits envelope renamed) so asRecord(payload)?.hits?.hits yields no array.","commonSituations":"Very rare or misspelled keywords with no matching Gitee repositories; searching Chinese-only terms with wrong encoding; Gitee silently changing the search API response shape (Elasticsearch-style hits.hits) so results are no longer where the parser expects.","solutions":["Retry with a different or broader keyword (fewer terms, English/Chinese variants)","Verify results exist by searching the same term at https://so.gitee.com in a browser","Check whether the Gitee search API response shape changed and update parsing of the hits envelope","Treat NOT_FOUND as an expected outcome in scripts (grep the error code) instead of a failure"],"exampleFix":"// before\nopencli gitee search --keyword \"zzqqxx999norepo\"   # NOT_FOUND\n// after\nopencli gitee search --keyword \"redis\"             # returns ranked rows","handlingStrategy":"fallback","validationCode":"if (!keyword || keyword.trim().length === 0) {\n  console.error('Provide a non-empty search keyword');\n  process.exit(1);\n}","typeGuard":"function isEmptyHits(payload) {\n  const hits = payload?.hits?.hits;\n  return !Array.isArray(hits) || hits.length === 0;\n}","tryCatchPattern":"try {\n  rows = await giteeSearch(keyword);\n} catch (e) {\n  if (e.code === 'NOT_FOUND') {\n    console.log(`No Gitee repos matched \"${keyword}\" — try a broader term.`);\n    rows = [];\n  } else throw e;\n}","preventionTips":["Treat empty result sets as expected outcomes, not crashes","Suggest broader/alternative keywords to users on zero hits","Sanity-check keywords against so.gitee.com in a browser during development","Watch for Gitee API shape changes if NOT_FOUND starts appearing for known-good terms"],"tags":["not-found","search","gitee","empty-results"],"backgroundTag":"no-search-results","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}