CherryHQ/cherry-studio · error · ModelscopeTaskFailedError

result.message || 'Task failed'

Error message

result.message || 'Task failed'

What it means

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.

Source

Thrown at src/main/ai/provider/custom/modelscope/modelscopeTransport.ts:156

        throw createAbortError('Task polling aborted')
      }

      try {
        const result = await this.request<ModelscopeTaskResult>(
          `/v1/tasks/${encodeURIComponent(taskId)}`,
          'GET',
          undefined,
          {
            timeout: 10000,
            signal,
            extraHeaders: { 'X-ModelScope-Task-Type': 'image_generation' }
          }
        )
        transientRetries = 0

        if (result.task_status === 'SUCCEED') return result
        if (result.task_status === 'FAILED') {
          throw new ModelscopeTaskFailedError(result.message || 'Task failed')
        }
      } catch (error) {
        if (signal?.aborted || (error instanceof Error && error.name === 'AbortError')) {
          throw createAbortError('Task polling aborted')
        }
        // Terminal failure or a 4xx (bar 429) poll response ends the loop;
        // 5xx / 429 fall through to transient retry.
        if (error instanceof ModelscopeTaskFailedError) {
          throw error
        }
        if (error instanceof ModelscopeApiError && isTerminalHttpStatus(error.statusCode)) {
          throw error
        }

        transientRetries++
        if (transientRetries >= maxTransientRetries) {
          throw error instanceof Error ? error : new Error(String(error))
        }

View on GitHub (pinned to 726446b54c)

Solutions

  1. Inspect the error message (vendor `result.message`) for the specific failure reason and adjust parameters.
  2. Retry — content-moderation and some quota failures are per-request.
  3. Verify the model id and parameter ranges against the api-inference docs.
Defensive patterns

Strategy: try-catch

Type guard

const isModelscopeTaskFailedError = (e: unknown): e is ModelscopeTaskFailedError =>
  e instanceof Error && e.name === 'ModelscopeTaskFailedError'

Try / catch

try {
  urls = await transport.poll(taskId, { signal })
} catch (e) {
  if (e instanceof ModelscopeTaskFailedError) {
    // terminal vendor failure — surface e.message to the user
    throw new Error(`Image generation failed: ${e.message}`)
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12). Data as JSON: /api/errors/e9a6db5c9e2f6d45. Report an issue: GitHub.