{"record":{"id":"fde4971800277218","repo":"jackwener/OpenCLI","slug":"error-fde497","errorCode":null,"errorMessage":"需要登录一亩三分地后再使用该命令","messagePattern":"需要登录一亩三分地后再使用该命令","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/1point3acres/utils.js","lineNumber":98,"sourceCode":"                }\n            } catch { /* try next */ }\n        }\n    }\n    if (seen.size > 0) {\n        return [...seen].map(([k, v]) => `${k}=${v}`).join('; ');\n    }\n    try {\n        const result = await page.evaluate('document.cookie');\n        return typeof result === 'string' ? result : '';\n    } catch {\n        return '';\n    }\n}\n\n/** Detect the \"you are a guest\" alert page that Discuz returns for protected actions. */\nexport function assertNotGuestAlert(html, domain = 'www.1point3acres.com') {\n    if (/<title>提示信息 \\| 一亩三分地<\\/title>/.test(html) && /无法进行此操作/.test(html)) {\n        throw new AuthRequiredError(domain, '需要登录一亩三分地后再使用该命令');\n    }\n}\n\nconst ENTITY_MAP = {\n    '&nbsp;': ' ', '&amp;': '&', '&lt;': '<', '&gt;': '>',\n    '&quot;': '\"', '&#39;': \"'\", '&apos;': \"'\",\n};\n\n/** Decode HTML entities (numeric + common named). */\nexport function decodeEntities(s) {\n    if (!s) return '';\n    return s\n        .replace(/&#(\\d+);/g, (_, n) => String.fromCodePoint(Number(n)))\n        .replace(/&#[xX]([0-9a-fA-F]+);/g, (_, n) => String.fromCodePoint(parseInt(n, 16)))\n        .replace(/&(nbsp|amp|lt|gt|quot|#39|apos);/g, m => ENTITY_MAP[m] || m);\n}\n\n/** Strip HTML tags and collapse whitespace, returning plain text. */","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/1point3acres/utils.js#L80-L116","documentation":"assertNotGuestAlert detects Discuz's standard 'guest cannot perform this action' page (title 提示信息 | 一亩三分地 plus the 无法进行此操作 marker) in fetched HTML. When found it throws AuthRequiredError telling the user they must log in to 1point3acres before the command can work, since protected forum actions require an authenticated session.","triggerScenarios":"Running any command that posts, replies, votes, favorites, or reads protected content on 1point3acres while the browser session is not logged in; the site responds with the Discuz guest-alert page and this guard fires.","commonSituations":"Cookie/session expired so the browser fell back to guest status; user never logged into the 1point3acres account in the connected browser; site invalidated sessions after a password change or security event; accessing members-only subforums.","solutions":["Log in to www.1point3acres.com in the browser session the CLI drives, then re-run the command.","Re-run the login command for this CLI (if provided) to refresh the session cookies.","Check in the browser that the session is actually authenticated (avatar visible, not guest).","If sessions keep expiring, re-login and avoid actions that invalidate the session (e.g. logging out elsewhere)."],"exampleFix":"// before\nawait cli.run('1p3a reply', { tid: '123456' }); // AuthRequiredError\n// after\nif (!(await cli.isLoggedIn('1point3acres'))) {\n    await cli.login('1point3acres');\n}\nawait cli.run('1p3a reply', { tid: '123456' });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"import { AuthRequiredError } from './errors.js';\ntry {\n    await runCommand();\n} catch (e) {\n    if (e instanceof AuthRequiredError) {\n        console.log(`Login to ${e.domain} required, opening browser...`);\n        await promptLogin(e.domain);\n    } else throw e;\n}","preventionTips":["Log in to 1point3acres in the CLI-connected browser before running protected commands","Check login state at session start and re-auth when expired","Avoid actions that invalidate the session (parallel logouts, password changes)","Keep session cookies persistent so restarts don't drop authentication"],"tags":["auth","login-required","discuz","forum"],"backgroundTag":"login-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}