{"record":{"id":"2fb7b8b543b52d87","repo":"jackwener/OpenCLI","slug":"checkresult-error","errorCode":null,"errorMessage":"${checkResult.error}","messagePattern":"\\$\\{checkResult\\.error\\}","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/v2ex/daily.js","lineNumber":61,"sourceCode":"          if (match) {\n            return { claimed: false, once: match[1], message: btn.value };\n          }\n        }\n        \n        return { \n          claimed: false, \n          error: '找到了按钮，但未能提取 once token',\n          debug_title: document.title,\n          debug_body: document.body.innerText.substring(0, 200).replace(/\\\\n/g, ' ')\n        };\n      }\n    `);\n        if (checkResult.error) {\n            if (process.env.OPENCLI_VERBOSE) {\n                console.error(`[opencli:v2ex:debug] Page Title: ${checkResult.debug_title}`);\n                console.error(`[opencli:v2ex:debug] Page Body: ${checkResult.debug_body}`);\n            }\n            throw new CommandExecutionError(checkResult.error);\n        }\n        if (checkResult.claimed) {\n            return [{ status: '✅ 已签到', message: checkResult.message }];\n        }\n        // Perform check in\n        if (process.env.OPENCLI_VERBOSE) {\n            console.error(`[opencli:v2ex] Found check-in token: once=${checkResult.once}. Checking in...`);\n        }\n        await page.goto(`https://www.v2ex.com/mission/daily/redeem?once=${checkResult.once}`);\n        await new Promise(resolve => setTimeout(resolve, 3000)); // wait longer for redirect\n        // Verify result\n        const verifyResult = await page.evaluate(`\n      async () => {\n        const btn = document.querySelector('input.super.normal.button');\n        if (!btn || !btn.value.includes('领取')) {\n          // fetch balance to show user\n          let balance = '';\n          const balanceLink = document.querySelector('a.balance_area');","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/v2ex/daily.js#L43-L79","documentation":"After navigating to https://www.v2ex.com/mission/daily, the command runs an in-page check script that returns {error: ...} when the page is not in the expected state. If checkResult.error is set, the command rethrows it as CommandExecutionError, optionally printing debug title/body when OPENCLI_VERBOSE is on. Typical cause: the daily-mission page didn't load as expected (not logged in, Cloudflare challenge, or V2EX markup/response changed).","triggerScenarios":"The page.evaluate check on /mission/daily returns an explicit error field — e.g. the mission box/ redeem button can't be found, the page is a sign-in redirect, or the DOM structure differs from what the check script expects.","commonSituations":"A2 session cookie expired so V2EX redirects to signin; Cloudflare interstitial not cleared within the 5-attempt bypass loop; V2EX renamed/relocated the daily-mission elements; account already redeemed in a way the script flags as an error.","solutions":["Re-run with OPENCLI_VERBOSE=1 to see the debug page title/body and identify what actually loaded.","Re-authenticate the v2ex session (run the v2ex login/verify flow) so /mission/daily doesn't redirect to signin.","Manually visit /mission/daily in the automation browser to clear any Cloudflare challenge, then retry.","If V2EX changed the mission-page DOM, update the check script selectors in clis/v2ex/daily.js."],"exampleFix":"// before\n$ opencli v2ex daily   # CommandExecutionError: <page error>\n// after\n$ OPENCLI_VERBOSE=1 opencli v2ex daily   # reveals debug_title/debug_body\n$ opencli v2ex login && opencli v2ex daily","handlingStrategy":"try-catch","validationCode":"OPENCLI_VERBOSE=1 opencli v2ex daily   # inspect debug_title/debug_body before fixing\n# ensure session first: cookies contain non-empty A2 for v2ex.com","typeGuard":"function pageCheckFailed(res) {\n  return !!res && typeof res === 'object' && typeof res.error === 'string' && res.error.length > 0;\n}","tryCatchPattern":"try {\n  await runDaily();\n} catch (e) {\n  console.error('Daily check failed:', e.message);\n  // re-authenticate v2ex session, clear Cloudflare, then retry once\n}","preventionTips":["Run with OPENCLI_VERBOSE=1 to capture debug page title/body on failure.","Refresh the V2EX session (A2 cookie) before daily runs, e.g. scheduled re-login.","Clear Cloudflare challenges interactively in the automation browser profile.","Track V2EX mission-page DOM changes and keep the check script selectors current."],"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"}