jackwener/OpenCLI · warning · EmptyResultError

bilibili user search: ${input}

Error message

bilibili user search: ${input}

What it means

resolveUid throws EmptyResultError('bilibili user search: ${input}') when the Bilibili user search succeeded structurally but returned zero results — meaning the lookup produced no user. It is a distinct, catchable signal that the username does not map to any account.

Source

Thrown at clis/bilibili/utils.js:301

    const payload = await apiGet(page, '/x/web-interface/wbi/search/type', {
        params: { search_type: 'bili_user', keyword: input },
        signed: true,
    });
    if (!payload || typeof payload !== 'object' || Array.isArray(payload) || !payload.data || typeof payload.data !== 'object' || Array.isArray(payload.data) || !Object.hasOwn(payload.data, 'result')) {
        throw new CommandExecutionError(`Bilibili user search returned malformed result for ${input}`);
    }
    const results = payload.data.result;
    if (!Array.isArray(results)) {
        throw new CommandExecutionError(`Bilibili user search returned malformed result for ${input}`);
    }
    if (results.length > 0) {
        const mid = String(results[0]?.mid ?? '').trim();
        if (!mid) {
            throw new CommandExecutionError(`Bilibili user search returned malformed mid for ${input}`);
        }
        return mid;
    }
    throw new EmptyResultError(`bilibili user search: ${input}`, 'User may not exist or username may have changed.');
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the username spelling and current Bilibili profile page
  2. Resolve by UID (number) instead of username via the uid command
  3. Catch EmptyResultError specifically and prompt the user to update the target username
  4. Use Bilibili's web UI search to confirm the account still exists under that name

Example fix

// before
const mid = await resolveTargetMid(args.user);
// after
try { const mid = await resolveTargetMid(args.user); }
catch (e) { if (e instanceof EmptyResultError) console.error(`No Bilibili user found for "${args.user}" — check the username or use --uid`); else throw e; }
Defensive patterns

Strategy: try-catch

Validate before calling

// sanity-check the username client-side before lookup
if (!/^[\w\-.\u4e00-\u9fa5]+$/.test(username)) throw new Error('suspicious username format');

Type guard

null

Try / catch

try { const mid = await resolveUid(name); }
catch (e) {
  if (e instanceof EmptyResultError) { console.warn(`No user "${name}" — may not exist or username changed`); }
  else throw e;
}

Prevention

When it happens

Trigger: Searching a username that no longer exists, was changed, or is not indexed by Bilibili search; calling mid/uid/resolveTargetMid with a typo'd or renamed username.

Common situations: User renamed their Bilibili account; typo in the username; searching for a deactivated/banned account; user set privacy settings hiding them from search.

Related errors


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