jackwener/OpenCLI · error · CommandExecutionError

Qianwen history API failed (status=${result.status}) ${resul

Error message

Qianwen history API failed (status=${result.status}) ${result.error || ''}

What it means

When getSessionListFromApi returns a non-ok response whose status is not 401/403 and there are no sessions to fall back on, the command throws CommandExecutionError `Qianwen history API failed (status=N) <error>` (clis/qwen/history.js:48, message trimmed). It signals the Qianwen history endpoint failed with a non-auth HTTP error (e.g. 5xx, 429) and no data could be retrieved.

Source

Thrown at clis/qwen/history.js:48

        { name: 'limit', type: 'int', default: 20, help: 'Max conversations to show (default 20, max 100)' },
    ],
    columns: ['Index', 'Title', 'Updated', 'Url'],
    func: async (page, kwargs) => {
        const limit = Number(kwargs.limit ?? 20);
        if (!Number.isInteger(limit) || limit <= 0) {
            throw new ArgumentError('limit must be a positive integer');
        }
        if (limit > 100) {
            throw new ArgumentError('limit must be <= 100');
        }
        await ensureOnQianwen(page);
        await dismissLoginModal(page);
        await page.wait(1);
        const result = await getSessionListFromApi(page, limit);
        if (!result.ok) {
            if (result.status === 401 || result.status === 403) throw authRequired();
            if (!result.sessions.length) {
                throw new CommandExecutionError(`Qianwen history API failed (status=${result.status}) ${result.error || ''}`.trim());
            }
        }
        if (!result.sessions.length) {
            throw new EmptyResultError('qwen history', 'No Qianwen conversations found.');
        }
        return result.sessions.slice(0, limit).map((s, i) => ({
            Index: i + 1,
            Title: s.title || '(untitled)',
            Updated: formatDate(s.updated_at),
            Url: `https://www.qianwen.com/chat/${s.id}`,
        }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry after a short wait; transient 5xx/429 often resolve (back off if 429).
  2. Re-authenticate with `qwen auth login` if the status suggests the session is stale, then retry.
  3. Update the CLI if Qianwen changed the API endpoint (a persistent 404 points to this).
  4. Check status.y/company status page or try again from a different network/proxy.

Example fix

// before (caller)
qwen history  # API failed (status=502)
// after
sleep 5 && qwen history  # retry with backoff; upgrade CLI if it persists
Defensive patterns

Strategy: retry

Try / catch

const fetchHistory = async (tries = 3) => {
  for (let i = 0; i < tries; i++) {
    try { return await qwenHistory({ limit: 20 }); }
    catch (e) {
      const m = /status=(\d+)/.exec(e.message);
      const s = m ? Number(m[1]) : 0;
      if (s === 401 || s === 403) throw e;          // re-auth instead of retry
      if (s === 429 || s >= 500) { await sleep(2 ** i * 1000); continue; }
      throw e;
    }
  }
  throw new Error('Qianwen history unavailable after retries');
};

Prevention

When it happens

Trigger: getSessionListFromApi(page, limit) returns {ok:false,status:<not 401/403>,sessions:[]} — server 500/502/503, rate limit 429, 404 after a Qianwen API path change, or a network-level fetch failure recorded with an error string.

Common situations: Qianwen API outage or maintenance; aggressive polling hitting rate limits; Qianwen renaming its internal session-list endpoint so the CLI's call 404s; flaky network through a proxy.

Related errors


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