jackwener/OpenCLI · error · AuthRequiredError

需要登录一亩三分地后再使用该命令

Error message

需要登录一亩三分地后再使用该命令

What it means

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.

Source

Thrown at clis/1point3acres/utils.js:98

                }
            } catch { /* try next */ }
        }
    }
    if (seen.size > 0) {
        return [...seen].map(([k, v]) => `${k}=${v}`).join('; ');
    }
    try {
        const result = await page.evaluate('document.cookie');
        return typeof result === 'string' ? result : '';
    } catch {
        return '';
    }
}

/** Detect the "you are a guest" alert page that Discuz returns for protected actions. */
export function assertNotGuestAlert(html, domain = 'www.1point3acres.com') {
    if (/<title>提示信息 \| 一亩三分地<\/title>/.test(html) && /无法进行此操作/.test(html)) {
        throw new AuthRequiredError(domain, '需要登录一亩三分地后再使用该命令');
    }
}

const ENTITY_MAP = {
    '&nbsp;': ' ', '&amp;': '&', '&lt;': '<', '&gt;': '>',
    '&quot;': '"', '&#39;': "'", '&apos;': "'",
};

/** Decode HTML entities (numeric + common named). */
export function decodeEntities(s) {
    if (!s) return '';
    return s
        .replace(/&#(\d+);/g, (_, n) => String.fromCodePoint(Number(n)))
        .replace(/&#[xX]([0-9a-fA-F]+);/g, (_, n) => String.fromCodePoint(parseInt(n, 16)))
        .replace(/&(nbsp|amp|lt|gt|quot|#39|apos);/g, m => ENTITY_MAP[m] || m);
}

/** Strip HTML tags and collapse whitespace, returning plain text. */

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log in to www.1point3acres.com in the browser session the CLI drives, then re-run the command.
  2. Re-run the login command for this CLI (if provided) to refresh the session cookies.
  3. Check in the browser that the session is actually authenticated (avatar visible, not guest).
  4. If sessions keep expiring, re-login and avoid actions that invalidate the session (e.g. logging out elsewhere).

Example fix

// before
await cli.run('1p3a reply', { tid: '123456' }); // AuthRequiredError
// after
if (!(await cli.isLoggedIn('1point3acres'))) {
    await cli.login('1point3acres');
}
await cli.run('1p3a reply', { tid: '123456' });
Defensive patterns

Strategy: try-catch

Try / catch

import { AuthRequiredError } from './errors.js';
try {
    await runCommand();
} catch (e) {
    if (e instanceof AuthRequiredError) {
        console.log(`Login to ${e.domain} required, opening browser...`);
        await promptLogin(e.domain);
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/fde4971800277218. Report an issue: GitHub.