{"record":{"id":"6adedf4cd822cc7c","repo":"fish2018/pansou","slug":"d-6adedf","errorCode":null,"errorMessage":"响应超过 %d 字节","messagePattern":"响应超过 (.+?) 字节","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/yingso/yingso.go","lineNumber":313,"sourceCode":"\treq.Header.Set(\"Origin\", websiteURL)\n\treq.Header.Set(\"Referer\", websiteURL+\"/\")\n\treq.Header.Set(\"User-Agent\", \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/124.0.0.0 Safari/537.36\")\n\tif payload != nil {\n\t\treq.Header.Set(\"Content-Type\", \"application/json\")\n\t}\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\tdata, err := io.ReadAll(io.LimitReader(resp.Body, maxResponseSize+1))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(data) > maxResponseSize {\n\t\treturn fmt.Errorf(\"响应超过 %d 字节\", maxResponseSize)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"HTTP %d: %s\", resp.StatusCode, strings.TrimSpace(string(data)))\n\t}\n\tif err := jsonutil.Unmarshal(data, target); err != nil {\n\t\treturn fmt.Errorf(\"解析响应失败: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc encryptPayload(payload interface{}, config apiConfig) (encryptedPayload, error) {\n\tno, err := randomToken(24)\n\tif err != nil {\n\t\treturn encryptedPayload{}, err\n\t}\n\tif config.Start < 0 || config.End <= config.Start || config.End > len(no) {\n\t\treturn encryptedPayload{}, fmt.Errorf(\"无效的加密区间 %d:%d\", config.Start, config.End)\n\t}","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/yingso/yingso.go#L295-L331","documentation":"requestJSON enforces a 1 MiB (maxResponseSize = 1<<20) cap on any response body by reading at most maxResponseSize+1 bytes via io.LimitReader; if more data is available, the response is assumed abnormal (e.g. an HTML error page, wrong endpoint, or a response bomb) and this error is returned instead of buffering unbounded memory.","triggerScenarios":"Any call through requestJSON — fetchConfig (/test), search (/search), resolveItem (/getKey) — where the Yingso server (or an intercepting proxy/CDN/WAF) returns a body larger than 1,048,576 bytes, such as a large HTML block/captcha page, a compressed-response mishap, or a compromised/misconfigured apiBaseURL pointing at the wrong server.","commonSituations":"The API is down and a load balancer returns a huge HTML error page; a captive portal or corporate proxy intercepts HTTPS and returns a large page; apiBaseURL was overridden to a debug/development endpoint that returns bulk data; the endpoint was redirected to something unexpected.","solutions":["Log the response's Content-Type and first bytes (via a small debug read) to see what oversized payload the server actually returned.","Verify p.apiBaseURL points at the real Yingso API (default https://ysapi.yingso.fun) and that no proxy/redirect is substituting a different server.","Retry after a short delay — if the Yingso API was briefly serving HTML error pages, the error is transient.","If legitimate API responses have grown beyond 1 MiB, raise the maxResponseSize constant (yingso.go:30) deliberately, accepting the memory tradeoff.","Check for CDN/WAF interception (challenge pages) and add matching headers or bypass the interceptor."],"exampleFix":"// before\nmaxResponseSize = 1 << 20\n// after\n// raise cap only if legitimate responses exceed 1 MiB\nmaxResponseSize = 4 << 20","handlingStrategy":"validation","validationCode":"// preflight: ensure endpoint is reachable and returns small JSON, not a huge page\nresp, err := client.Head(apiBaseURL + \"/test\")\nif err == nil {\n\tif cl := resp.Header.Get(\"Content-Length\"); cl != \"\" {\n\t\tif n, _ := strconv.Atoi(cl); n > 1<<20 {\n\t\t\tlog.Println(\"endpoint returns oversized responses; check apiBaseURL/proxy\")\n\t\t}\n\t}\n}","typeGuard":null,"tryCatchPattern":"config, err := p.fetchConfig(ctx, client)\nif err != nil {\n\tif strings.Contains(err.Error(), \"响应超过\") {\n\t\t// oversized/intercepted response: likely proxy/WAF or wrong endpoint\n\t\treturn nil, fmt.Errorf(\"yingso returned abnormal oversized body; check network/proxy: %w\", err)\n\t}\n\treturn nil, err\n}","preventionTips":["Point apiBaseURL at the official endpoint and avoid proxies that rewrite responses.","Detect HTML/captcha interception early by checking Content-Type before full reads.","Only raise maxResponseSize deliberately; keep the memory cap as a safety net.","Retry once on this error — oversized bodies are often transient gateway error pages."],"tags":["http","response-size","limit","safety"],"backgroundTag":"payload-too-large","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"}