jackwener/OpenCLI · warning · CliError
NOT_FOUND
NOT_FOUND
Error message
No Gitee repository search results found
What it means
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.
Source
Thrown at clis/gitee/search.js:107
apiUrl.searchParams.set('size', String(fetchSize));
await page.goto(searchUrl);
await page.wait(2);
const response = await fetch(apiUrl.toString(), {
headers: {
Accept: 'application/json',
'User-Agent': 'Mozilla/5.0',
Referer: searchUrl,
},
});
if (!response.ok) {
throw new CliError('REQUEST_FAILED', `Failed to request Gitee search API: ${response.status}`, 'Try again later or verify network access to so.gitee.com');
}
const payload = await response.json();
const payloadRecord = asRecord(payload);
const hitsRecord = asRecord(payloadRecord?.hits);
const rawRows = Array.isArray(hitsRecord?.hits) ? hitsRecord.hits : [];
if (rawRows.length === 0) {
throw new CliError('NOT_FOUND', 'No Gitee repository search results found', 'Try a different keyword or check whether Gitee search API changed');
}
const seen = new Set();
const rows = [];
for (let i = 0; i < rawRows.length && rows.length < limit; i++) {
const row = asRecord(rawRows[i]);
const fields = asRecord(row?.fields);
if (!fields)
continue;
const name = normalizeText(getFirstText(fields.title));
const repoUrl = normalizeUrl(getFirstText(fields.url));
if (!name || !repoUrl)
continue;
if (seen.has(repoUrl))
continue;
seen.add(repoUrl);
rows.push({
rank: rows.length + 1,
name,View on GitHub (pinned to 49907e53dc)
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
Example fix
// before opencli gitee search --keyword "zzqqxx999norepo" # NOT_FOUND // after opencli gitee search --keyword "redis" # returns ranked rows
Defensive patterns
Strategy: fallback
Validate before calling
if (!keyword || keyword.trim().length === 0) {
console.error('Provide a non-empty search keyword');
process.exit(1);
} Type guard
function isEmptyHits(payload) {
const hits = payload?.hits?.hits;
return !Array.isArray(hits) || hits.length === 0;
} Try / catch
try {
rows = await giteeSearch(keyword);
} catch (e) {
if (e.code === 'NOT_FOUND') {
console.log(`No Gitee repos matched "${keyword}" — try a broader term.`);
rows = [];
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: NOT_FOUND error code: why tRPC, Harbor, Nacos and other libraries return 404 "not found" errors for resources that may still exist — this error's family across 11 libraries.
Related errors
- NOT_FOUND
- NOT_FOUND
- No items match "${query}" on archive.org.
- No hotels rendered (${totalText}). Try a broader destination
- No Douyin videos matched "${keyword}".
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/fa9c5a687a7a0ab4.
Report an issue: GitHub.