jackwener/OpenCLI · error · CommandExecutionError
quark: ${action}: ${resp.message}
Error message
quark: ${action}: ${resp.message} What it means
unwrapApiData throws CommandExecutionError(`quark: ${action}: ${resp.status/message}`) when the Quark API returns a non-200 business status that is NOT recognized as an auth failure. The action label (e.g. the API operation name) and the API's own message are surfaced so the developer can see exactly which call failed and why, per Quark's resp.status/resp.message envelope.
Source
Thrown at clis/quark/utils.js:24
const AUTH_HINT = 'Quark Drive requires a logged-in browser session';
function isAuthFailure(message, status) {
if (status === 401 || status === 403)
return true;
return /not logged in|login required|please log in|authentication required|unauthorized|forbidden|未登录|请先登录|需要登录|登录/.test(message.toLowerCase());
}
function getErrorStatus(error) {
if (!error || typeof error !== 'object' || !('status' in error))
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 => {View on GitHub (pinned to 49907e53dc)
Solutions
- Read the embedded resp.message — it is Quark's own error text and names the concrete cause.
- Refresh fids via a fresh listing before mutating operations; stale ids are a common cause.
- Check storage quota and share-link validity for save operations.
- Add delays/backoff between bulk API calls if rate limiting is indicated.
- If messages look truncated or generic, verify unwrapApiData still matches Quark's current response envelope.
Example fix
// before: ignoring API business status
await apiPost(page, url, payload);
// after: inspect the returned result for status info
const result = await apiPost(page, url, payload);
if (result && result.status && result.status !== 200) {
console.error('quark api said:', result.message);
} Defensive patterns
Strategy: try-catch
Type guard
function isQuarkApiError(e) {
return e instanceof CommandExecutionError &&
/^quark: /.test(e.message);
} Try / catch
try {
await apiPost(page, url, payload);
} catch (e) {
if (isQuarkApiError(e)) {
const apiMsg = e.message.replace(/^quark: [^:]+: /, '');
console.error('Quark rejected the request:', apiMsg);
// branch on known messages: stale fid / quota / rate limit
} else throw e;
} Prevention
- Refresh fids from listings immediately before mutations.
- Respect rate limits: add delays/backoff in bulk scripts.
- Check quota and share validity before save operations.
- Log the embedded resp.message verbatim for diagnosis.
When it happens
Trigger: apiPost/apiGet responses with business error statuses: deleting/moving nonexistent fids, renaming to an invalid or duplicate name, saving a share that no longer exists, insufficient storage quota, rate limiting, or any other Quark-declared error.
Common situations: Stale fids from cached listings (files already deleted); renaming a file to a name that already exists; saving an expired share link; hitting Quark rate limits during bulk scripts; Quark API message format changes.
Related errors
- Zhihu ${label} returned an error payload: ${payload.__errorM
- ${probe.detail}
- Bilibili creator comparison API failed: ${message} (${payloa
- 获取视频分P信息失败: ${payload?.message ?? 'unknown'} (${payload?.cod
- 获取关注列表失败: ${payload.message} (${payload.code})
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/6980d63491cb8453.
Report an issue: GitHub.