{"record":{"id":"55464cfb6040ae4a","repo":"jackwener/OpenCLI","slug":"data-error-55464c","errorCode":null,"errorMessage":"${data.error}","messagePattern":"\\$\\{data\\.error\\}","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/v2ex/me.js","lineNumber":96,"sourceCode":"            debug_title: document.title,\n            debug_body: document.body.innerText.substring(0, 200).replace(/\\\\n/g, ' ')\n          };\n        }\n\n        return {\n          username,\n          balance,\n          unread_notifications,\n          daily_reward_ready: daily_reward_ready ? '是' : '否'\n        };\n      }\n    `);\n        if (data.error) {\n            if (process.env.OPENCLI_VERBOSE) {\n                console.error(`[opencli:v2ex:debug] Page Title: ${data.debug_title}`);\n                console.error(`[opencli:v2ex:debug] Page Body: ${data.debug_body}`);\n            }\n            throw new CommandExecutionError(data.error);\n        }\n        return [data];\n    },\n});\n","sourceCodeStart":78,"sourceCodeEnd":101,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/v2ex/me.js#L78-L101","documentation":"The v2ex me command evaluates a DOM-extraction script on the homepage; when that script returns {error: ...} the command wraps it in CommandExecutionError (with debug title/body logged when OPENCLI_VERBOSE is set). It indicates the profile page was not in the expected logged-in state, so username/balance/notifications could not be extracted.","triggerScenarios":"The in-page script on https://www.v2ex.com/ returns an explicit error — typically because the top-bar member link or balance elements are absent (anonymous session, Cloudflare page, or changed V2EX markup).","commonSituations":"Expired A2 cookie causing logged-out homepage; Cloudflare challenge surviving the 5-attempt wait loop; V2EX DOM redesign breaking the extraction selectors; account restricted page rendered instead of the normal homepage.","solutions":["Re-run with OPENCLI_VERBOSE=1 to inspect debug_title/debug_body and see which page actually loaded.","Re-login to V2EX (run the v2ex auth flow) so the homepage renders the logged-in top bar.","Manually clear any Cloudflare challenge in the automation browser, then retry.","Update the extraction script selectors in clis/v2ex/me.js if V2EX changed its DOM."],"exampleFix":"// before\n$ opencli v2ex me   # CommandExecutionError: <page error>\n// after\n$ OPENCLI_VERBOSE=1 opencli v2ex me\n$ opencli v2ex login && opencli v2ex me","handlingStrategy":"try-catch","validationCode":"OPENCLI_VERBOSE=1 opencli v2ex me   # reveals which page actually loaded via debug_title/debug_body","typeGuard":"function extractionFailed(data) {\n  return !!data && typeof data === 'object' && typeof data.error === 'string' && data.error.length > 0;\n}","tryCatchPattern":"try {\n  const [me] = await runMe();\n} catch (e) {\n  console.error('v2ex me failed:', e.message);\n  // re-login to v2ex and clear any challenge page, then retry\n}","preventionTips":["Keep an active A2 session cookie; re-login when verification fails.","Use OPENCLI_VERBOSE=1 for debug page title/body when extraction errors appear.","Manually clear Cloudflare interstitials in the persistent browser profile.","Update homepage extraction selectors when V2EX redesigns its top bar."],"tags":["browser-automation","scraping","dom-parsing"],"backgroundTag":"page-state-check-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}