jackwener/OpenCLI · error · ArgumentError
Invalid Quark share URL: ${url}
Error message
Invalid Quark share URL: ${url} What it means
extractPwdId in clis/quark/utils.js throws ArgumentError when the given share URL matches neither the /s/<id> path pattern nor a bare alphanumeric pwd id. This value (pwd_id) is required for all share operations (getToken, saveShare), so the command fails fast before any API call.
Source
Thrown at clis/quark/utils.js:32
return undefined;
const status = error.status;
return typeof status === 'number' ? status : undefined;
}
function unwrapApiData(resp, action) {
if (resp.status === 200)
return resp.data;
if (isAuthFailure(resp.message, resp.status)) {
throw new AuthRequiredError(QUARK_DOMAIN, AUTH_HINT);
}
throw new CommandExecutionError(`quark: ${action}: ${resp.message}`);
}
export function extractPwdId(url) {
const m = url.match(/\/s\/([a-zA-Z0-9]+)/);
if (m)
return m[1];
if (/^[a-zA-Z0-9]+$/.test(url))
return url;
throw new ArgumentError(`Invalid Quark share URL: ${url}`);
}
export async function fetchJson(page, url, options) {
const method = options?.method || 'GET';
const body = options?.body ? JSON.stringify(options.body) : undefined;
const js = `fetch(${JSON.stringify(url)}, {
method: ${JSON.stringify(method)},
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
${body ? `body: ${JSON.stringify(body)},` : ''}
}).then(async r => {
const ct = r.headers.get('content-type') || '';
if (!ct.includes('json')) {
const text = await r.text().catch(() => '');
throw Object.assign(new Error('Non-JSON response: ' + text.slice(0, 200)), { status: r.status });
}
return r.json();
})`;
try {View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the canonical share URL of the form https://pan.quark.cn/s/<alnum-id>.
- Alternatively pass just the bare alphanumeric share id (e.g. abc123def).
- Trim surrounding quotes, whitespace, or markdown from the pasted URL.
- Resolve redirector/short links to the final pan.quark.cn/s/... URL before invoking.
- If Quark changed URL format, update the extractPwdId regex accordingly.
Example fix
// before
const pwdId = extractPwdId('"https://pan.quark.cn/s/abc123"'); // quotes included
// after
const url = raw.trim().replace(/^["'<]|["'>]$/g, '');
const pwdId = extractPwdId(url); Defensive patterns
Strategy: validation
Validate before calling
function normalizeShareUrl(raw) {
const s = String(raw || '').trim().replace(/["'<>/]/g, m => m === '/' ? '/' : '');
const m = s.match(/pan\.quark\.cn\/s\/([a-zA-Z0-9]+)/);
if (!m && !/^[a-zA-Z0-9]+$/.test(s)) {
throw new Error(`Not a valid Quark share link or id: ${raw}`);
}
return m ? m[1] : s;
} Type guard
function isQuarkShareUrl(u) {
return typeof u === 'string' &&
(/pan\.quark\.cn\/s\/[a-zA-Z0-9]+/.test(u) || /^[a-zA-Z0-9]+$/.test(u.trim()));
} Prevention
- Trim quotes/markdown from pasted share links before use.
- Resolve short/redirect links to the canonical pan.quark.cn/s/... form.
- Validate the URL matches the /s/<alnum> pattern in scripts before invoking save.
When it happens
Trigger: Passing a full HTML page URL with extra query/hash that the regex still fails on (e.g. different domain path), a wrapped/redirector URL, a URL with percent-encoded or malformed share id, or pasting a title/description instead of the link.
Common situations: Copying a share link from an app that emits short/redirect URLs; including surrounding markdown or quotes around the URL; Quark changing its share URL format; passing a share code with punctuation or hyphens.
Related errors
- '${rawInput}' does not look like an autohome series id (a nu
- bilibili follow target must be a valid space.bilibili.com/<u
- chatgpt project commands require a chatgpt.com project id or
- Invalid Chess.com game URL: "${value}" Expected https://www.
- event query parameter must be a numeric event id
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/189bcf99a1095dde.
Report an issue: GitHub.