{"record":{"id":"c68e7a12a8558379","repo":"jackwener/OpenCLI","slug":"http-probe-httpstatus-from-quark-account-info","errorCode":null,"errorMessage":"HTTP ${probe.httpStatus} from Quark account/info","messagePattern":"HTTP (.+?) from Quark account/info","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/quark/auth.js","lineNumber":29,"sourceCode":"    if (!r.ok) return { kind: 'http', httpStatus: r.status };\n    const d = await r.json();\n    const data = d && d.data;\n    const isEmpty = !data || Array.isArray(data) || Object.keys(data).length === 0;\n    if (isEmpty) return { kind: 'auth', detail: 'Quark account/info returned empty data — anonymous' };\n    const nickname = String(data.nickname || data.nick_name || data.name || '');\n    if (!nickname) return { kind: 'render-error', detail: 'Quark account/info populated but no nickname field — response shape drift' };\n    return { ok: true, nickname };\n  } catch (e) {\n    return { kind: 'exception', detail: String(e && e.message || e) };\n  }\n})()`;\n\nasync function verifyQuarkIdentity(page) {\n  await page.goto('https://pan.quark.cn/');\n  await page.wait(2);\n  const probe = await page.evaluate(WHOAMI_PROBE);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('quark.cn', probe.detail);\n  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Quark account/info`);\n  if (probe?.kind === 'render-error') throw new CommandExecutionError(probe.detail);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`Quark whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Quark probe: ${JSON.stringify(probe)}`);\n  return { nickname: probe.nickname };\n}\n\nregisterSiteAuthCommands({\n  site: 'quark',\n  domain: 'quark.cn',\n  loginUrl: 'https://pan.quark.cn/',\n  columns: ['nickname'],\n  verify: verifyQuarkIdentity,\n  poll: async (page) => {\n    const probe = await page.evaluate(WHOAMI_PROBE);\n    if (!probe?.ok) throw new AuthRequiredError('quark.cn', 'Waiting for Quark login');\n    return { nickname: probe.nickname };\n  },\n});","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/quark/auth.js#L11-L47","documentation":"verifyQuarkIdentity probes the logged-in Quark (pan.quark.cn) page via WHOAMI_PROBE, which calls the account/info endpoint from page context. When that HTTP request returns a non-2xx status, the probe reports kind 'http' and this CommandExecutionError is thrown with the status code embedded. It means the identity check could not complete because the Quark API rejected or failed the request at the transport level (not an auth redirect and not a JS exception).","triggerScenarios":"WHOAMI_PROBE's fetch of Quark account/info returns an HTTP error status (e.g. 403, 429, 5xx) during verifyQuarkIdentity, typically when running the quark whoami/identity verification command against pan.quark.cn.","commonSituations":"Quark rate-limiting or WAF blocking automated requests; Quark API returning 5xx during outage or maintenance; regional/CDN blocks; expired cookies producing a non-redirect error status; API endpoint contract change after a Quark frontend update.","solutions":["Retry after a delay — transient 429/5xx responses are the most common cause; back off and re-run the identity check.","Verify the browser session is valid by opening pan.quark.cn in the automated page and confirming you are logged in; re-authenticate if cookies were cleared (AuthRequiredError would normally cover this, but odd statuses can stem from half-valid sessions).","Inspect probe.httpStatus to identify the cause: 429 = slow down, 403 = blocked/WAF, 5xx = server-side, and act accordingly.","Update the library/WHOAMI_PROBE if Quark changed its account/info endpoint, since an old URL can yield 404.","Check network/proxy configuration between the automation environment and quark.cn."],"exampleFix":"// before\nawait cli.run(['quark', 'whoami']); // throws CommandExecutionError on HTTP 429\n// after\ntry {\n  await cli.run(['quark', 'whoami']);\n} catch (e) {\n  if (String(e.message).includes('HTTP 429')) {\n    await new Promise(r => setTimeout(r, 30_000));\n    await cli.run(['quark', 'whoami']);\n  } else throw e;\n}","handlingStrategy":"retry","validationCode":"// Best-effort pre-check: ensure a session cookie for quark.cn exists before probing\nconst cookies = await page.cookies('https://pan.quark.cn/');\nif (!cookies.some(c => /session|token|__pus/i.test(c.name))) {\n  throw new Error('No Quark session cookie; run `quark login` first');\n}","typeGuard":"function isHttpProbe(p) {\n  return !!p && typeof p === 'object' && p.kind === 'http' && typeof p.httpStatus === 'number';\n}","tryCatchPattern":"try {\n  await verifyQuarkIdentity(page);\n} catch (e) {\n  const m = /HTTP (\\d{3}) from Quark/.exec(String(e.message));\n  if (m && (m[1] === '429' || m[1].startsWith('5'))) {\n    await sleep(30000); // back off and retry transient statuses\n  } else {\n    throw e;\n  }\n}","preventionTips":["Reuse a warm, logged-in browser profile so requests look routine","Apply exponential backoff on 429/5xx instead of immediate retries","Keep the tool updated so WHOAMI_PROBE targets the current Quark API URL","Check probe.httpStatus in logs to classify failures before acting"],"tags":["http","quark","network","probe"],"backgroundTag":"http-error-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}