{"record":{"id":"246535152f83b132","repo":"fish2018/pansou","slug":"s-w-246535","errorCode":null,"errorMessage":"[%s] 读取响应失败: %w","messagePattern":"\\[(.+?)\\] 读取响应失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/ikantv/ikantv.go","lineNumber":95,"sourceCode":"\treq.Header.Set(\"User-Agent\", \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36\")\n\treq.Header.Set(\"Accept\", \"application/json, text/plain, */*\")\n\treq.Header.Set(\"Accept-Language\", \"zh-CN,zh;q=0.9,en;q=0.8\")\n\treq.Header.Set(\"Connection\", \"keep-alive\")\n\treq.Header.Set(\"Referer\", defaultReferer)\n\n\tresp, err := p.doRequestWithRetry(req, client)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索请求失败: %w\", p.Name(), err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"[%s] 请求返回状态码: %d\", p.Name(), resp.StatusCode)\n\t}\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 读取响应失败: %w\", p.Name(), err)\n\t}\n\n\tvar apiResp apiResponse\n\tif err := json.Unmarshal(body, &apiResp); err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] JSON解析失败: %w\", p.Name(), err)\n\t}\n\tif apiResp.Code != 0 {\n\t\treturn nil, fmt.Errorf(\"[%s] API错误: %s\", p.Name(), apiResp.Message)\n\t}\n\n\tresults := convertResults(apiResp.Data)\n\treturn plugin.FilterResultsByKeyword(results, keyword), nil\n}\n\nfunc convertResults(items []apiItem) []model.SearchResult {\n\tresults := make([]model.SearchResult, 0, len(items))\n\tfor _, item := range items {\n\t\tresult, ok := convertResult(item)","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/ikantv/ikantv.go#L77-L113","documentation":"ikantv plugin's doSearch throws this when io.ReadAll(resp.Body) fails after a 200 response. The response body could not be read to completion — the connection dropped mid-transfer or a transport-level read failed.","triggerScenarios":"io.ReadAll(resp.Body) returns err on a 200 response: unexpected EOF from an abruptly closed connection, reset by peer, or read deadline hit while streaming the body.","commonSituations":"Upstream or CDN closes keep-alive connections prematurely; large responses interrupted by an unstable network; client Transport ReadTimeout shorter than the body transfer.","solutions":["Retry the request; a mid-body drop is typically transient.","Review the HTTP client's Transport timeouts (ResponseHeaderTimeout vs overall context) to ensure the body has time to transfer.","Disable connection reuse if stale keep-alive connections repeatedly reset.","Treat repeated occurrences as an upstream/network stability problem and log the wrapped io error."],"exampleFix":"// before\nbody, err := io.ReadAll(resp.Body)\nif err != nil {\n\treturn nil, fmt.Errorf(\"[%s] 读取响应失败: %w\", p.Name(), err)\n}\n// after\nbody, err := io.ReadAll(io.LimitReader(resp.Body, maxBodySize))\nif err != nil {\n\treturn nil, fmt.Errorf(\"[%s] 读取响应失败: %w\", p.Name(), err)\n}\nif len(body) == 0 {\n\treturn nil, fmt.Errorf(\"[%s] 响应体为空\", p.Name())\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"results, err := p.doSearch(ctx, keyword)\nif err != nil && strings.Contains(err.Error(), \"读取响应失败\") {\n\t// transient body read failure: retry once after a short backoff\n\ttime.Sleep(500 * time.Millisecond)\n\tresults, err = p.doSearch(ctx, keyword)\n}","preventionTips":["Retry mid-body read failures — they are usually transient","Use io.LimitReader to cap transfer size on unstable links","Match Transport read timeouts to expected body sizes","Investigate repeated occurrences as upstream/CDN instability"],"tags":["io","go","response-body","network"],"backgroundTag":"file-read-failed","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}