{"record":{"id":"f9e038f0655770ad","repo":"chenhg5/cc-connect","slug":"qq-http-s-invalid-response","errorCode":null,"errorMessage":"qq: HTTP %s invalid response","messagePattern":"qq: HTTP (.+?) invalid response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/qq/qq.go","lineNumber":626,"sourceCode":"\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"qq: HTTP %s failed: %w\", action, err)\n\t}\n\tdefer resp.Body.Close()\n\n\traw, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"qq: HTTP %s read body: %w\", action, err)\n\t}\n\n\tvar apiResp struct {\n\t\tStatus  string          `json:\"status\"`\n\t\tRetCode int             `json:\"retcode\"`\n\t\tData    json.RawMessage `json:\"data\"`\n\t\tMessage string          `json:\"message\"`\n\t}\n\tif json.Unmarshal(raw, &apiResp) != nil {\n\t\treturn nil, fmt.Errorf(\"qq: HTTP %s invalid response\", action)\n\t}\n\tif apiResp.RetCode != 0 {\n\t\treturn nil, fmt.Errorf(\"qq: HTTP %s failed (retcode=%d, msg=%s)\", action, apiResp.RetCode, apiResp.Message)\n\t}\n\tvar result map[string]any\n\t_ = json.Unmarshal(apiResp.Data, &result)\n\treturn result, nil\n}\n\n// ── Helpers ─────────────────────────────────────────────────────\n\ntype replyContext struct {\n\tmessageType string // \"private\" or \"group\"\n\tuserID      int64\n\tgroupID     int64\n\tmessageID   int32\n}\n","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/qq/qq.go#L608-L644","documentation":"callHTTPAPI returns this when the QQ HTTP API response body cannot be unmarshaled into the expected JSON envelope (status/retcode/data/message). It indicates the endpoint responded with something other than the OneBot JSON protocol — the shape of the response is wrong, not the transport.","triggerScenarios":"json.Unmarshal(raw, &apiResp) fails in callHTTPAPI: endpoint returned HTML (error page), empty body, truncated JSON, or a non-OneBot API at the configured URL.","commonSituations":"Configured URL points at a web UI instead of the OneBot HTTP API; proxy returns an HTML error page; server returned a 5xx with a non-JSON body; version change in the OneBot implementation altering the response format.","solutions":["Log the raw response body on failure to see what the server actually returned.","Verify the configured endpoint URL is the OneBot HTTP API (e.g. http://127.0.0.1:5700), not a web dashboard.","Confirm the QQ server implementation (go-cqhttp/Lagrange etc.) speaks the expected OneBot v11 JSON format.","Check for a reverse proxy intercepting the request with HTML error pages."],"exampleFix":"// before\nif json.Unmarshal(raw, &apiResp) != nil {\n    return nil, fmt.Errorf(\"qq: HTTP %s invalid response\", action)\n}\n// after\nif err := json.Unmarshal(raw, &apiResp); err != nil {\n    return nil, fmt.Errorf(\"qq: HTTP %s invalid response: %w (body=%s)\", action, err, string(raw))\n}","handlingStrategy":"validation","validationCode":"// Go: sanity-check the endpoint returns OneBot JSON before use\nresp, err := http.Get(\"http://127.0.0.1:5700/get_version_info\")\nif err != nil { return err }\nvar probe struct{ RetCode int `json:\"retcode\"` }\nif json.NewDecoder(resp.Body).Decode(&probe) != nil || resp.Header.Get(\"Content-Type\") == \"text/html\" {\n    return fmt.Errorf(\"endpoint does not speak OneBot JSON\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    return fmt.Errorf(\"qq api returned non-JSON body (check endpoint URL and proxies)\")\n}","preventionTips":["Point config at the OneBot HTTP API port, not the web UI.","Add Content-Type checking (application/json) before unmarshaling in your own probes.","Pin/test your OneBot server version after upgrades."],"tags":["qq","json","http-response","protocol"],"backgroundTag":"invalid-json-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"}