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
- Verify the username spelling and current Bilibili profile page
- Resolve by UID (number) instead of username via the uid command
- Catch EmptyResultError specifically and prompt the user to update the target username
- 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
- Catch EmptyResultError separately from CommandExecutionError
- Confirm usernames against bilibili.com before automation
- Store and reuse numeric mids instead of re-resolving names
- Handle renamed/deleted accounts gracefully in scripts
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
- bilibili pinned comments: ${bvid}
- bilibili comment replies: ${parent}
- bilibili creator-stats ${bvid}
- 此视频没有发现外挂或智能字幕。
- 字幕文件中没有字幕片段。
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c68c1dc057cb6758.
Report an issue: GitHub.