{"record":{"id":"ce1caa336b19c8e7","repo":"jackwener/OpenCLI","slug":"gitee-whoami-failed-probe-detail","errorCode":null,"errorMessage":"Gitee whoami failed: ${probe.detail}","messagePattern":"Gitee whoami failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/gitee/auth.js","lineNumber":25,"sourceCode":"  try {\n    const r = await fetch('/api/v5/user', { credentials: 'include', headers: { Accept: 'application/json' } });\n    if (r.status === 401 || r.status === 403) return { kind: 'auth', detail: 'Gitee /api/v5/user HTTP ' + r.status };\n    if (!r.ok) return { kind: 'http', httpStatus: r.status };\n    const d = await r.json();\n    if (!d || !d.id || !d.login) return { kind: 'auth', detail: 'Gitee /api/v5/user has no id/login — anonymous' };\n    return { ok: true, user_id: String(d.id), username: String(d.login), name: String(d.name || '') };\n  } catch (e) {\n    return { kind: 'exception', detail: String(e && e.message || e) };\n  }\n})()`;\n\nasync function verifyGiteeIdentity(page) {\n  await page.goto('https://gitee.com/');\n  await page.wait(1);\n  const probe = await page.evaluate(WHOAMI_PROBE);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('gitee.com', probe.detail);\n  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Gitee /api/v5/user`);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`Gitee whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Gitee probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, username: probe.username, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'gitee',\n  domain: 'gitee.com',\n  loginUrl: 'https://gitee.com/login',\n  columns: ['user_id', 'username', 'name'],\n  verify: verifyGiteeIdentity,\n  poll: async (page) => {\n    const probe = await page.evaluate(WHOAMI_PROBE);\n    if (!probe?.ok) throw new AuthRequiredError('gitee.com', 'Waiting for Gitee login');\n    return { user_id: probe.user_id, username: probe.username, name: probe.name };\n  },\n});\n","sourceCodeStart":7,"sourceCodeEnd":42,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gitee/auth.js#L7-L42","documentation":"In verifyGiteeIdentity (clis/gitee/auth.js), when the in-page WHOAMI_PROBE fetch itself throws (network failure, CORS, aborted request, JSON fetch exception), the probe returns kind 'exception' with the browser-side error text, and this CommandExecutionError wraps it as 'Gitee whoami failed: <detail>'. It means the identity probe could not complete at all, as opposed to receiving an HTTP response.","triggerScenarios":"page.evaluate of WHOAMI_PROBE runs while the page is on a non-gitee.com origin (fetch to '/api/v5/user' fails or is blocked), the network connection drops mid-request, the request is blocked by CSP/extension, or the page navigates/closes before the async probe resolves.","commonSituations":"Offline or flaky network; the automated browser sitting on an error/blank page instead of gitee.com; an extension or content-blocking tool killing the fetch; the browser tab being closed during the login poll.","solutions":["Confirm the page is actually on https://gitee.com/ when the probe runs (page.goto may have failed or been redirected).","Check basic network connectivity from the machine running the browser.","Disable extensions/content blockers in the automated browser profile.","Re-run the command; the detail text identifies the underlying browser-side fetch error."],"exampleFix":"// before — navigating without checking where we ended up\nawait page.goto('https://gitee.com/');\nconst identity = await verifyGiteeIdentity(page);\n// after — assert origin before probing\nawait page.goto('https://gitee.com/', { waitUntil: 'domcontentloaded' });\nif (!String(page.url()).includes('gitee.com')) throw new Error('Navigation to gitee.com failed');\nconst identity = await verifyGiteeIdentity(page);","handlingStrategy":"retry","validationCode":"if (!navigator.onLine) throw new Error('No network connection — cannot probe Gitee identity');","typeGuard":"function isProbeFailure(e) { return e instanceof Error && e.message.startsWith('Gitee whoami failed:'); }","tryCatchPattern":"try {\n  const identity = await verifyGiteeIdentity(page);\n} catch (err) {\n  if (err.message.startsWith('Gitee whoami failed:')) {\n    // network-level fetch failure: check connectivity/page origin, then retry\n  } else throw err;\n}","preventionTips":["Ensure page.goto('https://gitee.com/') succeeded before probing (check the final URL).","Run the probe only on the gitee.com origin so the relative fetch resolves.","Disable script-blocking extensions in the automation profile.","Add a small settle delay after navigation before evaluating the probe."],"tags":["gitee","network","fetch-failed","browser-automation"],"backgroundTag":"fetch-network-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}