jackwener/OpenCLI · info · EmptyResultError

1point3acres user

Error message

1point3acres user

What it means

EmptyResultError thrown when the fetched user profile (space-uid-*.html / space-username-*.html) is a Discuz '提示信息' notice page containing 没有找到/不存在 — meaning the user does not exist or the profile is inaccessible as a guest. The requested `who` value is echoed in the detail.

Source

Thrown at clis/1point3acres/user.js:36

    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        { name: 'who', required: true, positional: true, help: '用户名或 uid(纯数字按 uid 查,否则按用户名)' },
    ],
    columns: [
        'uid', 'username', 'group', 'credits', 'rice',
        'posts', 'threads', 'digests', 'registerTime', 'lastAccess', 'profileUrl',
    ],
    func: async (args) => {
        const who = String(args.who || '').trim();
        if (!who) throw new ArgumentError('who 不能为空', '传用户名或数字 uid');
        const url = /^\d+$/.test(who)
            ? `${BASE}/space-uid-${who}.html`
            : `${BASE}/space-username-${encodeURIComponent(who)}.html`;

        const html = await fetchHtml(url);
        if (/<title>提示信息/.test(html) && /(没有找到|不存在)/.test(html)) {
            throw new EmptyResultError('1point3acres user', `用户 "${who}" 不存在`);
        }

        const pick = (re) => {
            const m = html.match(re);
            return m ? decodeEntities(m[1].trim()) : '';
        };
        // <li>KEY: VAL</li>   — tolerant of optional <span>, colons fullwidth/半角, 颗/根/粒 suffixes.
        const pickLi = (label) => {
            const re = new RegExp(`<li>\\s*${label}[::\\s]*(?:<[^>]+>)?\\s*([^<]+?)\\s*(?:<|$)`);
            const m = html.match(re);
            return m ? decodeEntities(m[1].trim()) : '';
        };

        const username =
            pick(/<p class="mtm[^"]*"[^>]*>\s*<a [^>]*>([^<]+?)<\/a>/) ||
            pick(/<title>([^<]+?)的个人资料/);
        const uid = pick(/uid=(\d+)/) || pick(/space-uid-(\d+)\.html/);
        const group = pickLi('用户组');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the username/uid exists by visiting the space URL in a browser
  2. Try the numeric uid instead of the username (avoids encoding/normalization issues)
  3. Trim and normalize the username (NFC) and retry — watch for invisible characters from copy-paste
  4. If the profile is visible in a browser but not via the CLI, the account likely requires login — the guest fetch cannot see it

Example fix

// before
user({ who: 'david' })  // full-width chars → user not found
// after
user({ who: 'david'.normalize('NFKC') })
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try {
  const profile = await user({ who });
} catch (e) {
  if (e instanceof EmptyResultError) {
    console.warn(`User "${who}" does not exist or is not visible as a guest`);
  } else throw e;
}

Prevention

When it happens

Trigger: Querying a uid that was never registered or was purged; a username with different Unicode normalization/whitespace than the account; querying a suspended/banned member whose space page is a notice; wrong URL-encoding of special characters in the username.

Common situations: User renamed their account; searching a nickname/display name instead of the actual login username; copied username containing invisible characters or full-width spaces; old uids recycled/removed on the forum.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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