jackwener/OpenCLI · error · CliError
FETCH_ERROR
FETCH_ERROR
Error message
Failed to parse Gitee Explore page
What it means
CliError with code FETCH_ERROR thrown when the in-page script evaluating the Gitee Explore page does not return an array of projects. The library runs a page.evaluate extraction of recommended projects; if the result is not an Array it concludes the page structure no longer matches and throws, hinting Gitee may have changed its page structure.
Source
Thrown at clis/gitee/trending.js:552
name,
description: pickDescription(card, name),
stars: extractStars(card),
url,
});
seen.add(url);
}
};
collect(root);
if (projects.length < 8 && root !== document) {
collect(document);
}
return projects;
})()
`);
if (!Array.isArray(rawProjects)) {
throw new CliError('FETCH_ERROR', 'Failed to parse Gitee Explore page', 'Gitee may have changed its page structure');
}
const projects = rawProjects
.map(toProject)
.filter((project) => project !== null)
.map((project) => mergeCapturedProject(project, projectsFromCapture.get(project.url)))
.map((project) => ({
...project,
description: compactDescription(project.description),
}))
.slice(0, limit);
if (projects.length === 0) {
throw new CliError('NOT_FOUND', 'No recommended projects found on Gitee Explore', 'Gitee may be blocking this request or the page structure changed');
}
return projects;
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Update the extraction script in clis/gitee/trending.js to match the current Explore DOM/embedded data
- Add a wait/retry before evaluate so the page fully renders before extraction
- Check manually in a browser whether gitee.com/explore serves a captcha or login wall and log in first
- Capture the actual page HTML/evaluate result to diff against the expected structure
Example fix
// before
if (!Array.isArray(rawProjects)) {
throw new CliError('FETCH_ERROR', 'Failed to parse Gitee Explore page', ...);
}
// after (defensive fallback)
const list = Array.isArray(rawProjects) ? rawProjects : [];
if (list.length === 0) {
await page.wait(3); // re-wait and retry extraction once
rawProjects = await page.evaluate(script);
} Defensive patterns
Strategy: retry
Validate before calling
// Ensure Explore content is present before extracting
await page.goto('https://gitee.com/explore');
await page.waitForSelector('.explore__project, .project-card', { timeout: 15000 }).catch(() => {}); Type guard
function isFetchError(e) {
return e instanceof Error && e.code === 'FETCH_ERROR';
} Try / catch
try {
projects = await giteeTrending();
} catch (e) {
if (e.code === 'FETCH_ERROR') {
console.error('Gitee Explore structure may have changed; retrying once...');
await page.reload();
projects = await giteeTrending();
} else throw e;
} Prevention
- Wait for the project-list selector before running the extraction script
- Diff Explore DOM snapshots periodically to detect redesigns early
- Detect captcha/login-wall pages before parsing and authenticate first
- Log raw evaluate output when the array check fails to speed up fixes
When it happens
Trigger: page.evaluate of the Explore extraction script returns undefined/null/an object — the DOM selectors or embedded data the script relies on no longer exist; page failed to load recommended-projects markup; blocked/captcha page returned instead of Explore content.
Common situations: Gitee redesigned the Explore page (class names, data attributes, embedded JSON moved); anti-bot interstitial or login wall served instead of the page; slow network so the extraction ran before content rendered; regional variant of gitee.com with different markup.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Not a git repository
- Working tree not clean: ${status}
- Ctrip attraction DOM extraction returned malformed rows
- Ctrip attraction links rendered but parser did not find requ
- Ctrip bus DOM extraction returned malformed rows
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/d3e8e75743b00648.
Report an issue: GitHub.