{"record":{"id":"a22a70202b8dcdc3","repo":"jackwener/OpenCLI","slug":"http-raw-httperror-hint-not-logged-in-to","errorCode":null,"errorMessage":"HTTP ${raw._httpError} — Hint: not logged in to ${DANJUAN_DOMAIN}?","messagePattern":"HTTP (.+?) — Hint: not logged in to (.+?)\\?","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/xueqiu/danjuan-utils.js","lineNumber":109,"sourceCode":"          });\n        }\n      }\n\n      return {\n        asOf:                root.daily_gain_date || null,\n        totalAssetAmount:    n(root.amount),\n        totalAssetDailyGain: n(root.daily_gain),\n        totalAssetHoldGain:  n(root.hold_gain),\n        totalAssetTotalGain: n(root.total_gain),\n        totalFundMarketValue:n(fundSec && fundSec.amount),\n        accounts,\n        holdings,\n        detailErrors,\n      };\n    })()\n  `);\n    if (raw?._httpError) {\n        throw new Error(`HTTP ${raw._httpError} — Hint: not logged in to ${DANJUAN_DOMAIN}?`);\n    }\n    if (raw?._emptyAccounts) {\n        throw new Error(`No fund accounts found — Hint: not logged in to ${DANJUAN_DOMAIN}?`);\n    }\n    if (Array.isArray(raw?.detailErrors) && raw.detailErrors.length > 0) {\n        const failedAccounts = raw.detailErrors\n            .map((item) => {\n            const label = item.accountName && item.accountId\n                ? `${item.accountName} (${item.accountId})`\n                : item.accountName || item.accountId || 'unknown account';\n            return `${label}: ${item.error}`;\n        })\n            .join(', ');\n        throw new Error(`Failed to fetch Danjuan account details: ${failedAccounts}`);\n    }\n    return raw;\n}\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xueqiu/danjuan-utils.js#L91-L127","documentation":"fetchDanjuanAll in clis/xueqiu/danjuan-utils.js evaluates in-page JavaScript on danjuanfunds.com and inspects the returned raw object. If the page script recorded an _httpError status, it throws this Error because Danjuan's API did not return data — most often the browser session's cookies are missing/expired, i.e. the user is not logged in to danjuanfunds.com.","triggerScenarios":"The in-page fetch to Danjuan's account APIs returns a non-2xx status stored in raw._httpError — typically HTTP 401/403 from expired or absent login cookies, anti-bot rejection, or network failure during the browser session.","commonSituations":"Danjuan login cookie expired (their sessions rotate frequently), running headless without importing browser cookies, IP flagged by Danjuan's anti-scraping, or Danjuan serving a login redirect.","solutions":["Log in to danjuanfunds.com in the browser session used by the tool (refresh cookies via the cookie/COOKIE strategy login flow) and retry.","Re-export fresh cookies from a logged-in browser if you supply them manually.","Check the reported HTTP status code: 401/403 => auth problem; 5xx => retry later.","Try from a different network/IP if anti-bot blocking is suspected.","Verify danjuanfunds.com is reachable and not down for maintenance."],"exampleFix":"// before (stale cookies)\nclis/xueqiu danjuan-funds   # HTTP 401 — Hint: not logged in to danjuanfunds.com?\n// after (re-login to refresh cookies, then)\nclis/xueqiu danjuan-funds","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const snapshot = await fetchDanjuanAll(page);\n} catch (err) {\n  if (/^HTTP \\d+/.test(err.message)) {\n    // refresh danjuanfunds.com cookies / re-login, then retry\n  } else throw err;\n}","preventionTips":["Keep danjuanfunds.com cookies fresh; re-login when sessions expire.","Check the HTTP code in the message to distinguish auth (401/403) from server (5xx) issues.","Avoid scraping from flagged IPs; verify connectivity first."],"tags":["http","authentication","cookies","danjuan"],"backgroundTag":"http-401-unauthorized","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}