{"record":{"id":"aba1d5d6e6c8e6f0","repo":"CherryHQ/cherry-studio","slug":"dashscope-task-status-tolowercase","errorCode":null,"errorMessage":"DashScope task ${status.toLowerCase()}","messagePattern":"DashScope task (.+?)","errorType":"exception","errorClass":"DashScopeTaskFailedError","httpStatus":null,"severity":"error","filePath":"src/main/ai/provider/custom/dashscope/dashscopeTransport.ts","lineNumber":467,"sourceCode":"    let attempts = 0\n    let transientRetries = 0\n    const startTime = Date.now()\n\n    while (attempts < maxAttempts) {\n      if (signal?.aborted) throw createAbortError('Task polling aborted')\n\n      try {\n        const result = await this.request<DashScopeTaskResult>(\n          `/api/v1/tasks/${encodeURIComponent(taskId)}`,\n          'GET',\n          undefined,\n          { timeout: 10000, signal }\n        )\n        transientRetries = 0\n        const status = result.output.task_status\n        if (status === 'SUCCEEDED') return result\n        if (status === 'FAILED' || status === 'CANCELED' || status === 'UNKNOWN') {\n          throw new DashScopeTaskFailedError(result.output.message || `DashScope task ${status.toLowerCase()}`)\n        }\n      } catch (error) {\n        if (signal?.aborted || (error instanceof Error && error.name === 'AbortError')) {\n          throw createAbortError('Task polling aborted')\n        }\n        // A terminal vendor failure or a 4xx (bar 429) poll response ends the\n        // loop; 5xx / 429 fall through to transient retry.\n        if (error instanceof DashScopeTaskFailedError) throw error\n        if (error instanceof DashScopeApiError && isTerminalHttpStatus(error.statusCode)) throw error\n\n        transientRetries++\n        if (transientRetries >= maxTransientRetries) {\n          throw error instanceof Error ? error : new Error(String(error))\n        }\n        const elapsedTime = Date.now() - startTime\n        const pollDelay = interval ?? (elapsedTime < 60000 ? 3000 : 10000)\n        await waitWithSignal(pollDelay, signal)\n        continue","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/provider/custom/dashscope/dashscopeTransport.ts#L449-L485","documentation":"Thrown as a `DashScopeTaskFailedError` during polling when `task_status` is `FAILED`, `CANCELED`, or `UNKNOWN`. The message is the vendor-provided `output.message` if present, otherwise a generic `DashScope task {status}`. This is a terminal condition — the remote async task will never produce images.","triggerScenarios":"The async image task ended in a non-success terminal state: content-moderation rejection, invalid generation parameters, quota/billing exhaustion, or an explicit vendor-side cancellation.","commonSituations":"Prompt or input image tripped DashScope's content filter; the account hit a concurrency/quota limit; unsupported parameter combination for the model; transient vendor outage marked the task UNKNOWN.","solutions":["Inspect the error message (vendor `output.message`) for the specific rejection reason and adjust the prompt/parameters accordingly.","Retry the generation — content-moderation and some quota failures are per-request.","Verify account quota/billing status in the DashScope (Bailian) console."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isDashScopeTaskFailedError = (e: unknown): e is DashScopeTaskFailedError =>\n  e instanceof Error && e.name === 'DashScopeTaskFailedError'","tryCatchPattern":"try {\n  urls = await transport.poll(taskId, { signal })\n} catch (e) {\n  if (e instanceof DashScopeTaskFailedError) {\n    // terminal vendor failure — surface e.message (vendor reason) to the user; do not retry blindly\n    throw new Error(`Image generation failed: ${e.message}`)\n  }\n  throw e\n}","preventionTips":["Surface the vendor message to the user so they can adjust the prompt","Retry once for content-moderation edge cases but don't loop on repeated failures","Check account quota before retrying quota-related failures"],"tags":["task-failed","dashscope","async","polling","content-moderation"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}