{"record":{"id":"e9a6db5c9e2f6d45","repo":"CherryHQ/cherry-studio","slug":"result-message-task-failed","errorCode":null,"errorMessage":"result.message || 'Task failed'","messagePattern":"result\\.message \\|\\| 'Task failed'","errorType":"exception","errorClass":"ModelscopeTaskFailedError","httpStatus":null,"severity":"error","filePath":"src/main/ai/provider/custom/modelscope/modelscopeTransport.ts","lineNumber":156,"sourceCode":"        throw createAbortError('Task polling aborted')\n      }\n\n      try {\n        const result = await this.request<ModelscopeTaskResult>(\n          `/v1/tasks/${encodeURIComponent(taskId)}`,\n          'GET',\n          undefined,\n          {\n            timeout: 10000,\n            signal,\n            extraHeaders: { 'X-ModelScope-Task-Type': 'image_generation' }\n          }\n        )\n        transientRetries = 0\n\n        if (result.task_status === 'SUCCEED') return result\n        if (result.task_status === 'FAILED') {\n          throw new ModelscopeTaskFailedError(result.message || 'Task failed')\n        }\n      } catch (error) {\n        if (signal?.aborted || (error instanceof Error && error.name === 'AbortError')) {\n          throw createAbortError('Task polling aborted')\n        }\n        // Terminal failure or a 4xx (bar 429) poll response ends the loop;\n        // 5xx / 429 fall through to transient retry.\n        if (error instanceof ModelscopeTaskFailedError) {\n          throw error\n        }\n        if (error instanceof ModelscopeApiError && isTerminalHttpStatus(error.statusCode)) {\n          throw error\n        }\n\n        transientRetries++\n        if (transientRetries >= maxTransientRetries) {\n          throw error instanceof Error ? error : new Error(String(error))\n        }","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/provider/custom/modelscope/modelscopeTransport.ts#L138-L174","documentation":"Thrown as a `ModelscopeTaskFailedError` during polling when `task_status === 'FAILED'`. The message is the vendor-provided `result.message` if present, otherwise a generic `'Task failed'`. This is a terminal condition — the ModelScope async image task will not produce output images.","triggerScenarios":"The ModelScope async image task failed on the vendor side: content-moderation rejection, invalid generation parameters (steps/guidance/size out of range), free-tier quota exhaustion, or an unsupported model.","commonSituations":"Prompt tripped ModelScope's content filter; `numInferenceSteps`/`guidanceScale` outside the model's accepted range; free-tier fair-use quota hit; the requested model id is not enabled.","solutions":["Inspect the error message (vendor `result.message`) for the specific failure reason and adjust parameters.","Retry — content-moderation and some quota failures are per-request.","Verify the model id and parameter ranges against the api-inference docs."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isModelscopeTaskFailedError = (e: unknown): e is ModelscopeTaskFailedError =>\n  e instanceof Error && e.name === 'ModelscopeTaskFailedError'","tryCatchPattern":"try {\n  urls = await transport.poll(taskId, { signal })\n} catch (e) {\n  if (e instanceof ModelscopeTaskFailedError) {\n    // terminal vendor failure — surface e.message to the user\n    throw new Error(`Image generation failed: ${e.message}`)\n  }\n  throw e\n}","preventionTips":["Surface the vendor message so the user can adjust params","Validate numInferenceSteps/guidanceScale ranges against the model docs","Retry once for per-request moderation/quota edge cases"],"tags":["task-failed","modelscope","async","polling","content-moderation"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}