{"record":{"id":"f212d54945ae0589","repo":"chenhg5/cc-connect","slug":"qwen-tts-api-d-s","errorCode":null,"errorMessage":"qwen tts API %d: %s","messagePattern":"qwen tts API (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tts.go","lineNumber":157,"sourceCode":"\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, q.BaseURL, bytes.NewReader(jsonData))\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"qwen tts: create request: %w\", err)\n\t}\n\treq.Header.Set(\"Authorization\", \"Bearer \"+q.APIKey)\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tresp, err := q.Client.Do(req)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"qwen tts: request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"qwen tts: read response: %w\", err)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, \"\", fmt.Errorf(\"qwen tts API %d: %s\", resp.StatusCode, body)\n\t}\n\n\tvar result struct {\n\t\tCode    string `json:\"code\"`\n\t\tMessage string `json:\"message\"`\n\t\tOutput  struct {\n\t\t\tAudio struct {\n\t\t\t\tURL string `json:\"url\"`\n\t\t\t} `json:\"audio\"`\n\t\t} `json:\"output\"`\n\t}\n\tif err := json.Unmarshal(body, &result); err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"qwen tts: parse response: %w\", err)\n\t}\n\tif result.Code != \"\" {\n\t\treturn nil, \"\", fmt.Errorf(\"qwen tts API error %s: %s\", result.Code, result.Message)\n\t}\n\tif result.Output.Audio.URL == \"\" {","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/tts.go#L139-L175","documentation":"If the TTS API responds with an HTTP status other than 200, Synthesize surfaces 'qwen tts API <status>: <body>', including the raw response body for diagnosis. This means the request reached the server and was rejected or failed server-side.","triggerScenarios":"resp.StatusCode != http.StatusOK — e.g. 401 for a bad/expired API key, 403 quota/permission, 404 wrong endpoint path, 429 rate limited, 5xx server error.","commonSituations":"Missing or revoked DASHSCOPE API key; free-tier quota exhausted; base URL pointing to a wrong path after an API version change; model name not enabled for the account; upstream outage.","solutions":["Read the status and body in the error: 401/403 -> fix the API key and its permissions; 429 -> back off and retry; 5xx -> retry later.","Verify the Authorization header input: ensure q.APIKey is set and valid for the Dashscope account.","Confirm the BaseURL path matches the current Qwen TTS API version.","Check account quota and model enablement in the provider console."],"exampleFix":"// before\nq := &core.QwenTTS{APIKey: os.Getenv(\"QWEN_KEY\"), BaseURL: oldURL} // key may be \"\"\n// after\nkey := os.Getenv(\"DASHSCOPE_API_KEY\")\nif key == \"\" { log.Fatal(\"DASHSCOPE_API_KEY not set\") }\nq := &core.QwenTTS{APIKey: key, BaseURL: currentAPIURL}","handlingStrategy":"try-catch","validationCode":"// fail fast before first user request\nif q.APIKey == \"\" {\n    return fmt.Errorf(\"missing TTS API key (set DASHSCOPE_API_KEY)\")\n}","typeGuard":null,"tryCatchPattern":"audio, _, err := q.Synthesize(ctx, text, opts)\nif err != nil {\n    var apiErr struct{ status string }\n    if strings.HasPrefix(err.Error(), \"qwen tts API \") {\n        switch {\n        case strings.Contains(err.Error(), \"401\"), strings.Contains(err.Error(), \"403\"):\n            return fmt.Errorf(\"check your TTS API key/permissions\")\n        case strings.Contains(err.Error(), \"429\"):\n            return retryAfterBackoff(ctx, text, opts)\n        default:\n            return err // 5xx: surface and retry later\n        }\n    }\n    return err\n}","preventionTips":["Verify the API key at startup with a lightweight request.","Handle 429 with rate-limit-aware backoff.","Keep the BaseURL in sync with the provider's current API version.","Log the included response body on non-200 for diagnosis."],"tags":["tts","qwen","http","api"],"backgroundTag":"http-error-response","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}