{"record":{"id":"e5ced3c36d20b24d","repo":"jackwener/OpenCLI","slug":"qianwen-history-api-failed-status-result-status","errorCode":null,"errorMessage":"Qianwen history API failed (status=${result.status}) ${result.error || ''}","messagePattern":"Qianwen history API failed \\(status=(.+?)\\) (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/qwen/history.js","lineNumber":48,"sourceCode":"        { name: 'limit', type: 'int', default: 20, help: 'Max conversations to show (default 20, max 100)' },\n    ],\n    columns: ['Index', 'Title', 'Updated', 'Url'],\n    func: async (page, kwargs) => {\n        const limit = Number(kwargs.limit ?? 20);\n        if (!Number.isInteger(limit) || limit <= 0) {\n            throw new ArgumentError('limit must be a positive integer');\n        }\n        if (limit > 100) {\n            throw new ArgumentError('limit must be <= 100');\n        }\n        await ensureOnQianwen(page);\n        await dismissLoginModal(page);\n        await page.wait(1);\n        const result = await getSessionListFromApi(page, limit);\n        if (!result.ok) {\n            if (result.status === 401 || result.status === 403) throw authRequired();\n            if (!result.sessions.length) {\n                throw new CommandExecutionError(`Qianwen history API failed (status=${result.status}) ${result.error || ''}`.trim());\n            }\n        }\n        if (!result.sessions.length) {\n            throw new EmptyResultError('qwen history', 'No Qianwen conversations found.');\n        }\n        return result.sessions.slice(0, limit).map((s, i) => ({\n            Index: i + 1,\n            Title: s.title || '(untitled)',\n            Updated: formatDate(s.updated_at),\n            Url: `https://www.qianwen.com/chat/${s.id}`,\n        }));\n    },\n});\n","sourceCodeStart":30,"sourceCodeEnd":62,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/history.js#L30-L62","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Retry after a short wait; transient 5xx/429 often resolve (back off if 429).","Re-authenticate with `qwen auth login` if the status suggests the session is stale, then retry.","Update the CLI if Qianwen changed the API endpoint (a persistent 404 points to this).","Check status.y/company status page or try again from a different network/proxy."],"exampleFix":"// before (caller)\nqwen history  # API failed (status=502)\n// after\nsleep 5 && qwen history  # retry with backoff; upgrade CLI if it persists","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"const fetchHistory = async (tries = 3) => {\n  for (let i = 0; i < tries; i++) {\n    try { return await qwenHistory({ limit: 20 }); }\n    catch (e) {\n      const m = /status=(\\d+)/.exec(e.message);\n      const s = m ? Number(m[1]) : 0;\n      if (s === 401 || s === 403) throw e;          // re-auth instead of retry\n      if (s === 429 || s >= 500) { await sleep(2 ** i * 1000); continue; }\n      throw e;\n    }\n  }\n  throw new Error('Qianwen history unavailable after retries');\n};","preventionTips":["Add exponential backoff for 5xx/429 statuses parsed from the message.","Don't poll the history API in tight loops; respect rate limits.","On persistent 404, upgrade the CLI — Qianwen may have changed the endpoint.","Monitor qianwen.com availability before assuming local misconfiguration."],"tags":["network","http","api","qwen"],"backgroundTag":"api-http-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}