jackwener/OpenCLI · error · CliError

REQUEST_FAILED

REQUEST_FAILED

Error message

Failed to read Gitee user profile API: ${apiResponse.status}

What it means

Thrown when the Gitee user profile API responds with a non-OK, non-404 status (e.g. 403 rate-limit, 500/502 server error). The CLI cannot read the profile and surfaces the upstream HTTP status in the message with a REQUEST_FAILED code, advising a retry or network check. It indicates a transient or upstream problem, not a bad username.

Source

Thrown at clis/gitee/user.js:185

        if (domSnapshot.notFound) {
            throw new CliError('NOT_FOUND', `Gitee user "${username}" does not exist`, 'Check the username and retry: opencli gitee user <username>');
        }
        if (domSnapshot.blocked) {
            throw new CliError('FORBIDDEN', `Gitee user page "${username}" is not accessible`, 'The profile may be private/restricted, or the account may be unavailable');
        }
        const apiUrl = `${GITEE_USER_API}/${encodeURIComponent(username)}`;
        const apiResponse = await fetch(apiUrl, {
            headers: {
                Accept: 'application/json',
                'User-Agent': 'Mozilla/5.0',
                Referer: profileUrl,
            },
        });
        if (apiResponse.status === 404) {
            throw new CliError('NOT_FOUND', `Gitee user "${username}" does not exist`, 'Check the username and retry: opencli gitee user <username>');
        }
        if (!apiResponse.ok) {
            throw new CliError('REQUEST_FAILED', `Failed to read Gitee user profile API: ${apiResponse.status}`, 'Try again later or verify network access to gitee.com');
        }
        const apiUser = asRecord(await apiResponse.json());
        const nickname = pickFirst(domSnapshot.nickname, firstText(apiUser?.name), firstText(apiUser?.login), username);
        const followers = pickFirst(domSnapshot.followers, normalizeCount(apiUser?.followers), '-');
        const publicRepos = pickFirst(domSnapshot.publicRepos, normalizeCount(apiUser?.public_repos), '-');
        const giteeIndex = pickFirst(domSnapshot.giteeIndex, apiGiteeIndex(apiUser), '-');
        return [
            { field: 'Nickname', value: nickname },
            { field: 'Followers', value: followers },
            { field: 'Public Repositories', value: publicRepos },
            { field: 'Gitee Index', value: giteeIndex },
            { field: 'URL', value: profileUrl },
        ];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the command after a short delay (the failure is often transient)
  2. Check general access to gitee.com from your environment (browser or curl)
  3. If behind a proxy/corporate network, configure proxy env vars or use a network with access to gitee.com
  4. If rate-limited, wait before retrying or use an authenticated access token if the CLI supports it

Example fix

// before (in a tight loop)
for (const u of users) await opencli gitee user u;
// after (backoff between calls)
for (const u of users) { await opencli gitee user u; await new Promise(r => setTimeout(r, 2000)); }
Defensive patterns

Strategy: retry

Validate before calling

const ok = await fetch('https://gitee.com', { method: 'HEAD' }).then(r => r.ok).catch(() => false);
if (!ok) throw new Error('gitee.com unreachable from this environment');

Type guard

function isRequestFailed(e) { return e instanceof Error && e.code === 'REQUEST_FAILED'; }

Try / catch

try {
  await run(['opencli', 'gitee', 'user', username]);
} catch (e) {
  if (e.code === 'REQUEST_FAILED' && attempt < 3) return retryWithBackoff(attempt + 1);
  throw e;
}

Prevention

When it happens

Trigger: `fetch` to the Gitee profile API returns status >= 400 and != 404 — for example 403 from rate limiting/anti-bot protection, 5xx from a Gitee outage, or a proxy returning an error status.

Common situations: Gitee rate-limiting anonymous API calls after repeated runs; corporate proxy or firewall intercepting requests; temporary gitee.com outage or maintenance; network DNS/connectivity problems surfacing as gateway errors.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/d7d50666556a2a42. Report an issue: GitHub.