{"record":{"id":"566664f685291ab3","repo":"chenhg5/cc-connect","slug":"marshal-request-w","errorCode":null,"errorMessage":"marshal request: %w","messagePattern":"marshal request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/speech.go","lineNumber":160,"sourceCode":"\t\t\"model\": q.Model,\n\t\t\"messages\": []map[string]any{\n\t\t\t{\n\t\t\t\t\"role\": \"user\",\n\t\t\t\t\"content\": []map[string]any{\n\t\t\t\t\t{\n\t\t\t\t\t\t\"type\": \"input_audio\",\n\t\t\t\t\t\t\"input_audio\": map[string]any{\n\t\t\t\t\t\t\t\"data\": dataURI,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tjsonData, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"marshal request: %w\", err)\n\t}\n\n\turl := q.BaseURL + \"/chat/completions\"\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(jsonData))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"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 \"\", fmt.Errorf(\"qwen asr request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/speech.go#L142-L178","documentation":"QwenASR.Transcribe builds a chat/completions request containing the audio as a base64 data URI and marshals it with encoding/json. json.Marshal can only fail here if a value in reqBody is unsupported (e.g. a channel, func, or cyclic value). With the current map[string]any structure of plain strings this is effectively unreachable; the wrap is defensive.","triggerScenarios":"json.Marshal returns an error for the request body — only possible if reqBody is modified to contain unsupported Go types (func, chan, or a value with a MarshalJSON method that returns an error).","commonSituations":"Essentially never hit by users; could appear if someone customizes the request-building code and inserts an unsupported type.","solutions":["Inspect the wrapped json error for the unsupported type name","Replace unsupported field types in reqBody with JSON-serializable types (string, []any, map[string]any)","Remove cyclic references if custom structs were introduced"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"text, err := stt.Transcribe(ctx, audio, format, lang)\nif err != nil && strings.Contains(err.Error(), \"marshal request\") {\n    slog.Error(\"qwen request body not JSON-serializable\", \"err\", err)\n}","preventionTips":["Keep reqBody limited to JSON-native types (string, map[string]any, []any)","Never insert func/chan values into request maps","If adding fields, test json.Marshal on the body in a unit test"],"tags":["json","stt","qwen"],"backgroundTag":"json-marshal-failed","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"}