{"record":{"id":"abb578fbd405da5b","repo":"SubtitleEdit/subtitleedit","slug":"dashscope-async-submit-returned-no-task-id-respon","errorCode":null,"errorMessage":"DashScope async submit returned no task_id. Response: {json}","messagePattern":"DashScope async submit returned no task_id\\. Response: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/ui/Features/Video/SpeechToText/DashScope/DashScopeSttService.cs","lineNumber":186,"sourceCode":"            Content = content,\n        };\n        request.Headers.Authorization = new AuthenticationHeaderValue(\"Bearer\", _settings.ApiKey);\n        request.Headers.TryAddWithoutValidation(\"X-DashScope-Async\", \"enable\");\n        request.Headers.TryAddWithoutValidation(\"X-DashScope-OssResourceResolve\", \"enable\");\n\n        using var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, ct);\n        var json = await response.Content.ReadAsStringAsync(ct);\n        if (!response.IsSuccessStatusCode)\n        {\n            _settings.Logger?.Invoke($\"DashScope async submit failed ({(int)response.StatusCode}): {json}\");\n            throw new HttpRequestException($\"DashScope async submit failed ({(int)response.StatusCode}). Response: {json}\");\n        }\n\n        var taskId = JsonSerializer.Deserialize<DashScopeTaskResponse>(json,\n            new JsonSerializerOptions { PropertyNameCaseInsensitive = true })?.Output?.TaskId;\n        if (string.IsNullOrEmpty(taskId))\n        {\n            throw new InvalidOperationException($\"DashScope async submit returned no task_id. Response: {json}\");\n        }\n\n        return taskId;\n    }\n\n    private async Task<string> PollTaskAsync(string taskId, CancellationToken ct)\n    {\n        var url = BaseUrl + TasksPath + Uri.EscapeDataString(taskId);\n        var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };\n\n        while (true)\n        {\n            ct.ThrowIfCancellationRequested();\n\n            using var request = new HttpRequestMessage(HttpMethod.Get, url);\n            request.Headers.Authorization = new AuthenticationHeaderValue(\"Bearer\", _settings.ApiKey);\n\n            using var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, ct);","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Features/Video/SpeechToText/DashScope/DashScopeSttService.cs#L168-L204","documentation":"Thrown when the async submit endpoint returns HTTP 200 but the deserialized response's Output.TaskId is null or empty. The response was successfully received and parsed, but the expected task_id field is missing, indicating the API accepted the request but didn't return a trackable task identifier.","triggerScenarios":"The response JSON has a different structure than DashScopeTaskResponse expects (Output or TaskId at a different nesting level); the API returned a 200 with a business-level error that doesn't populate TaskId; PropertyNameCaseInsensitive deserialization mapped incorrectly.","commonSituations":"DashScope changed the response envelope structure; the response contains an error object at the top level instead of the expected output.task_id path; a field rename (e.g. task_id vs taskId vs id) that case-insensitive matching doesn't bridge.","solutions":["Inspect the raw json in the error message to see the actual response structure.","If the structure changed, update DashScopeTaskResponse and its nested Output class to match.","Check if the response contains an error/status field that explains why no task was created.","Verify PropertyNameCaseInsensitive is correctly mapping 'task_id' to TaskId — test with a known-good response."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check for known error fields before deserializing task_id\nusing var doc = JsonDocument.Parse(json);\nif (doc.RootElement.TryGetProperty(\"output\", out var output) &&\n    output.TryGetProperty(\"task_id\", out var taskIdProp) &&\n    taskIdProp.ValueKind == JsonValueKind.String)\n{ /* safe to deserialize normally */ }\nelse\n    throw new InvalidOperationException($\"Response lacks output.task_id. Raw: {json}\");","typeGuard":null,"tryCatchPattern":"try { var taskId = DeserializeTaskId(json); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"no task_id\"))\n{ /* log raw JSON, check for business error in response, surface to user */ }","preventionTips":["Log the raw JSON for any missing-field error.","Pin to a known DashScope API version if versioning is available.","Check the response for error/status fields that explain the missing task_id.","Monitor DashScope changelog for response envelope changes."],"tags":["deserialization","dashscope","speech-to-text","schema-mismatch"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}