{"record":{"id":"c56882469918216d","repo":"chenhg5/cc-connect","slug":"create-request-w","errorCode":null,"errorMessage":"create request: %w","messagePattern":"create request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/speech.go","lineNumber":79,"sourceCode":"\n\tpart, err := writer.CreateFormFile(\"file\", \"audio.\"+ext)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"create form file: %w\", err)\n\t}\n\tif _, err := part.Write(audio); err != nil {\n\t\treturn \"\", fmt.Errorf(\"write audio: %w\", err)\n\t}\n\t_ = writer.WriteField(\"model\", w.Model)\n\t_ = writer.WriteField(\"response_format\", \"text\")\n\tif lang != \"\" {\n\t\t_ = writer.WriteField(\"language\", lang)\n\t}\n\twriter.Close()\n\n\turl := w.BaseURL + \"/audio/transcriptions\"\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, url, &buf)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"create request: %w\", err)\n\t}\n\treq.Header.Set(\"Authorization\", \"Bearer \"+w.APIKey)\n\treq.Header.Set(\"Content-Type\", writer.FormDataContentType())\n\n\tresp, err := w.Client.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"whisper 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 \"\", fmt.Errorf(\"read response: %w\", err)\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"whisper API %d: %s\", resp.StatusCode, string(body))\n\t}","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/speech.go#L61-L97","documentation":"http.NewRequestWithContext failed while constructing the POST to BaseURL + '/audio/transcriptions'. NewRequestWithContext returns an error for an unparseable/invalid URL or an unsupported method, so this points at a malformed BaseURL configured on the OpenAIWhisper instance.","triggerScenarios":"Transcribe called with OpenAIWhisper.BaseURL containing invalid URL syntax (spaces, control characters, missing scheme such as 'api.openai.com/v1' without https://).","commonSituations":"Typo or bad paste in config.toml for the whisper base_url; missing scheme; trailing whitespace or newline in an env-provided URL; misconfigured self-hosted proxy URL.","solutions":["Check BaseURL for missing scheme — it must start with http:// or https://","Trim whitespace/newlines from the configured base_url value","Validate the URL with url.Parse before constructing OpenAIWhisper","Fall back to the default https://api.openai.com/v1 (NewOpenAIWhisper does this only when BaseURL is empty, not invalid)"],"exampleFix":"// before (config.toml)\nbase_url = \"api.openai.com/v1\"\n// after\nbase_url = \"https://api.openai.com/v1\"","handlingStrategy":"validation","validationCode":"u, err := url.Parse(cfg.BaseURL)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"invalid whisper base_url %q: %w\", cfg.BaseURL, err)\n}","typeGuard":null,"tryCatchPattern":"text, err := stt.Transcribe(ctx, audio, format, lang)\nif err != nil && strings.Contains(err.Error(), \"create request\") {\n    slog.Error(\"whisper base_url is malformed\", \"err\", err)\n    return \"\"\n}","preventionTips":["Always include the https:// scheme in base_url config values","Trim whitespace from URL values loaded from env/config","Run url.Parse on configured URLs at startup (fail fast), not at request time"],"tags":["http","url","whisper","config"],"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"}