{"record":{"id":"d3e8e75743b00648","repo":"jackwener/OpenCLI","slug":"fetch-error-d3e8e7","errorCode":"FETCH_ERROR","errorMessage":"Failed to parse Gitee Explore page","messagePattern":"Failed to parse Gitee Explore page","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/gitee/trending.js","lineNumber":552,"sourceCode":"              name,\n              description: pickDescription(card, name),\n              stars: extractStars(card),\n              url,\n            });\n            seen.add(url);\n          }\n        };\n\n        collect(root);\n        if (projects.length < 8 && root !== document) {\n          collect(document);\n        }\n\n        return projects;\n      })()\n    `);\n        if (!Array.isArray(rawProjects)) {\n            throw new CliError('FETCH_ERROR', 'Failed to parse Gitee Explore page', 'Gitee may have changed its page structure');\n        }\n        const projects = rawProjects\n            .map(toProject)\n            .filter((project) => project !== null)\n            .map((project) => mergeCapturedProject(project, projectsFromCapture.get(project.url)))\n            .map((project) => ({\n            ...project,\n            description: compactDescription(project.description),\n        }))\n            .slice(0, limit);\n        if (projects.length === 0) {\n            throw new CliError('NOT_FOUND', 'No recommended projects found on Gitee Explore', 'Gitee may be blocking this request or the page structure changed');\n        }\n        return projects;\n    },\n});\n","sourceCodeStart":534,"sourceCodeEnd":569,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gitee/trending.js#L534-L569","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nif (!Array.isArray(rawProjects)) {\n    throw new CliError('FETCH_ERROR', 'Failed to parse Gitee Explore page', ...);\n}\n// after (defensive fallback)\nconst list = Array.isArray(rawProjects) ? rawProjects : [];\nif (list.length === 0) {\n    await page.wait(3);            // re-wait and retry extraction once\n    rawProjects = await page.evaluate(script);\n}","handlingStrategy":"retry","validationCode":"// Ensure Explore content is present before extracting\nawait page.goto('https://gitee.com/explore');\nawait page.waitForSelector('.explore__project, .project-card', { timeout: 15000 }).catch(() => {});","typeGuard":"function isFetchError(e) {\n  return e instanceof Error && e.code === 'FETCH_ERROR';\n}","tryCatchPattern":"try {\n  projects = await giteeTrending();\n} catch (e) {\n  if (e.code === 'FETCH_ERROR') {\n    console.error('Gitee Explore structure may have changed; retrying once...');\n    await page.reload();\n    projects = await giteeTrending();\n  } else throw e;\n}","preventionTips":["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"],"tags":["scraping","dom-parsing","gitee","page-structure-change"],"backgroundTag":"page-structure-change","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}