{"record":{"id":"60737defafaa5c7d","repo":"chenhg5/cc-connect","slug":"qwen-tts-create-request-w","errorCode":null,"errorMessage":"qwen tts: create request: %w","messagePattern":"qwen tts: create request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tts.go","lineNumber":141,"sourceCode":"\treqBody := map[string]any{\n\t\t\"model\": q.Model,\n\t}\n\tinput := map[string]any{\n\t\t\"text\":  text,\n\t\t\"voice\": voice,\n\t}\n\tif opts.LanguageType != \"\" {\n\t\tinput[\"language_type\"] = opts.LanguageType\n\t}\n\treqBody[\"input\"] = input\n\tjsonData, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"qwen tts: marshal request: %w\", err)\n\t}\n\n\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","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/tts.go#L123-L159","documentation":"After marshaling, Synthesize builds the HTTP POST request with http.NewRequestWithContext against q.BaseURL. If request construction fails (invalid method/URL, malformed base URL) the error is wrapped as 'qwen tts: create request'. It indicates the outgoing request could not even be created.","triggerScenarios":"http.NewRequestWithContext returns an error, almost always because q.BaseURL is not a valid absolute URL (empty, missing scheme, contains spaces or control characters).","commonSituations":"Config missing or mistyping the TTS base URL; env var for the endpoint unset leaving BaseURL empty; a trailing typo or whitespace pasted into the configured URL.","solutions":["Check the TTS base_url in config.toml — it must be a full URL like https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation.","Verify the env var backing BaseURL is set and has no stray whitespace or quotes.","Validate the URL with url.ParseRequestURI before constructing the client/client options."],"exampleFix":"// before\nq := &core.QwenTTS{BaseURL: cfg.TTSBaseURL} // may be \"\"\n// after\nif u, err := url.Parse(cfg.TTSBaseURL); err != nil || u.Scheme == \"\" {\n    log.Fatal(\"invalid tts base_url\")\n}\nq := &core.QwenTTS{BaseURL: cfg.TTSBaseURL}","handlingStrategy":"validation","validationCode":"u, err := url.ParseRequestURI(cfg.TTSBaseURL)\nif err != nil || u.Scheme != \"https\" && u.Scheme != \"http\" {\n    return fmt.Errorf(\"invalid tts base_url: %q\", cfg.TTSBaseURL)\n}","typeGuard":null,"tryCatchPattern":"audio, _, err := q.Synthesize(ctx, text, opts)\nif err != nil && strings.Contains(err.Error(), \"create request\") {\n    slog.Error(\"qwen tts: check base_url config\", \"err\", err)\n    return fmt.Errorf(\"TTS is misconfigured (check base_url): %w\", err)\n}","preventionTips":["Validate base_url at config load time, not at request time.","Fail fast at startup if the TTS endpoint is unset.","Trim whitespace from configured URLs.","Pin the endpoint in config.example.toml with a known-good value."],"tags":["tts","qwen","http","url"],"backgroundTag":"invalid-url","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}