jackwener/OpenCLI · error · ArgumentError
xiaohongshu/follow: invalid profile URL
Error message
xiaohongshu/follow: invalid profile URL
What it means
assertUserId accepts either a raw user ID or a full profile URL. If the input looks like a URL (starts with http:// or https://) but new URL() cannot parse it, an ArgumentError (exit code 2, usage error) is thrown. This means the argument is syntactically not a valid URL at all.
Source
Thrown at clis/xiaohongshu/follow.js:47
return host === 'xiaohongshu.com' || host.endsWith('.xiaohongshu.com');
}
function requireActionResult(payload, context) {
const inner = unwrapEvaluateResult(payload);
if (!inner || typeof inner !== 'object' || Array.isArray(inner) || typeof inner.ok !== 'boolean') {
throw new CommandExecutionError(`xiaohongshu/follow: malformed ${context} payload`);
}
return inner;
}
function assertUserId(raw) {
const input = String(raw ?? '').trim();
if (/^https?:\/\//i.test(input)) {
let parsed;
try {
parsed = new URL(input);
} catch {
throw new ArgumentError('xiaohongshu/follow: invalid profile URL');
}
if (parsed.protocol !== 'https:' || !isXiaohongshuHost(parsed.hostname)) {
throw new ArgumentError('xiaohongshu/follow: profile URL must be an exact https://*.xiaohongshu.com URL');
}
const match = parsed.pathname.match(/^\/user\/profile\/([a-zA-Z0-9]{8,32})\/?$/);
if (!match) {
throw new ArgumentError('xiaohongshu/follow: profile URL must be /user/profile/<userId>');
}
return match[1];
}
const userId = normalizeXhsUserId(raw);
if (!userId || !USER_ID_RE.test(userId)) {
throw new ArgumentError(
'xiaohongshu/follow: user-id must be a Xiaohongshu user ID (e.g. 5d8f88dc0000000001005d3a) or full profile URL',
);
}
return userId;
}View on GitHub (pinned to 49907e53dc)
Solutions
- Fix the URL syntax — it must be a valid absolute URL like https://www.xiaohongshu.com/user/profile/<userId>.
- Alternatively pass just the raw 24-char user ID (e.g. 5d8f88dc0000000001005d3a) instead of a URL.
- Trim whitespace and re-copy the URL from the browser address bar without markdown or quotes.
Example fix
// before opencli xiaohongshu follow --user-id 'https//www.xiaohongshu.com/user/profile/5d8f88dc0000000001005d3a' // after opencli xiaohongshu follow --user-id 'https://www.xiaohongshu.com/user/profile/5d8f88dc0000000001005d3a'
Defensive patterns
Strategy: validation
Validate before calling
function isValidProfileUrl(raw) {
const s = String(raw ?? '').trim();
if (!/^https?:\/\//i.test(s)) return true; // treated as user id
try { new URL(s); return true; } catch { return false; }
} Try / catch
try {
await opencliFollow(userIdArg);
} catch (err) {
if (err.code === 'ARGUMENT') {
console.error(`Bad --user-id: ${userIdArg}. Use a user ID or full https URL.`);
process.exitCode = 2;
} else throw err;
} Prevention
- Copy URLs directly from the browser address bar
- Trim whitespace from CLI arguments before passing
- Prefer passing the raw 24-char user ID over URLs
- Quote URLs in shell to avoid mangling
When it happens
Trigger: Passing something like 'https//www.xiaohongshu.com/user/profile/5d8f...' (missing colon), 'https:// user profile', or a URL with stray spaces/newlines to the --user-id option of the xiaohongshu follow command.
Common situations: Copy-paste truncation from a terminal (protocol mangled); shell quoting stripping characters; manually typing the URL with typos; pasting markdown-wrapped URLs with trailing punctuation.
Related errors
- xiaohongshu/follow: profile URL must be /user/profile/<userI
- xiaohongshu/follow: user-id must be a Xiaohongshu user ID (e
- <train-no> must not be empty
- 1688 item expects an offer URL or offer ID
- Invalid 1688 store URL
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/151e2668901e98dd.
Report an issue: GitHub.