{"record":{"id":"8791bf537d5306e9","repo":"SubtitleEdit/subtitleedit","slug":"dashscope-transcription-task-status-response","errorCode":null,"errorMessage":"DashScope transcription task {status}. Response: {json}","messagePattern":"DashScope transcription task (.+?)\\. Response: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/ui/Features/Video/SpeechToText/DashScope/DashScopeSttService.cs","lineNumber":226,"sourceCode":"                throw new HttpRequestException($\"DashScope task poll failed ({(int)response.StatusCode}). Response: {json}\");\n            }\n\n            var output = JsonSerializer.Deserialize<DashScopeTaskResponse>(json, options)?.Output;\n            var status = output?.TaskStatus ?? \"UNKNOWN\";\n            switch (status.ToUpperInvariant())\n            {\n                case \"SUCCEEDED\":\n                    var transcriptionUrl = output?.Result?.TranscriptionUrl\n                        ?? (output?.Results != null && output.Results.Count > 0 ? output.Results[0].TranscriptionUrl : null);\n                    if (string.IsNullOrEmpty(transcriptionUrl))\n                    {\n                        throw new InvalidOperationException($\"DashScope task succeeded but returned no transcription_url. Response: {json}\");\n                    }\n                    return transcriptionUrl;\n\n                case \"FAILED\":\n                case \"UNKNOWN\":\n                    throw new InvalidOperationException($\"DashScope transcription task {status}. Response: {json}\");\n\n                default: // QUEUED, PENDING, PROCESSING\n                    await Task.Delay(TimeSpan.FromSeconds(3), ct);\n                    break;\n            }\n        }\n    }\n\n    /// <summary>\n    /// Serialize the async submit body. <c>enable_words</c> adds word-level\n    /// timings; a fixed language is sent only when the user set one.\n    /// </summary>\n    internal static string BuildSubmitBody(DashScopeSttSettings settings, string fileUrl, string? language)\n    {\n        var languageToUse = language ?? settings.Language;\n\n        using var stream = new MemoryStream();\n        using (var writer = new Utf8JsonWriter(stream))","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Features/Video/SpeechToText/DashScope/DashScopeSttService.cs#L208-L244","documentation":"Thrown when the polled task status is FAILED or UNKNOWN (case-insensitive). The task did not succeed — DashScope explicitly reported failure or returned an unrecognized status string. The full JSON response is included for diagnosis. QUEUED/PENDING/PROCESSING statuses fall through to the default case and continue polling.","triggerScenarios":"The ASR engine encountered an error processing the audio (corrupt audio, unsupported codec, audio too short); the task was killed by DashScope's internal timeout; the model encountered an internal error; an UNKNOWN status from an unrecognized response field.","commonSituations":"The uploaded audio file is corrupt or in an unsupported format; the audio is too short (below minimum duration); the model crashed server-side; the audio bitrate/sample rate is outside the model's supported range; the task exceeded DashScope's maximum processing time.","solutions":["Examine the json response body for DashScope's error details (error_message, error_code fields).","Verify the audio file is valid and in a supported format (WAV, MP3, FLAC, etc. — check DashScope ASR docs).","Check the audio file's sample rate and bitrate are within the model's supported range.","If the audio is very short, pad it or use a different model that handles short clips.","Re-encode the audio to a standard format (16kHz mono WAV) and retry.","For UNKNOWN status, check if the response uses a new status string not in the switch cases."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-validate audio format before submitting to DashScope\nvar info = GetAudioInfo(audioFilePath);\nif (info.Duration.TotalSeconds < 0.5)\n    throw new InvalidOperationException(\"Audio is too short for transcription (minimum 0.5 seconds).\");\nif (!SupportedFormats.Contains(info.Container))\n    throw new InvalidOperationException($\"Audio format '{info.Container}' may not be supported by DashScope ASR.\");","typeGuard":null,"tryCatchPattern":"try { var result = await service.TranscribeAsync(path, lang, progress, segProgress, ct); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"transcription task FAILED\") || ex.Message.Contains(\"UNKNOWN\"))\n{ /* parse JSON for error details, re-encode audio, or switch model */ }","preventionTips":["Pre-validate audio format, sample rate, and duration before submission.","Re-encode problematic audio to 16kHz mono WAV as a safe baseline format.","Parse the FAILED response JSON for server-side error codes to guide fixes.","Keep a fallback ASR engine available for when DashScope rejects specific audio."],"tags":["api-error","dashscope","speech-to-text","transcription-failed"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}