{"record":{"id":"ebda68ae143178cd","repo":"fish2018/pansou","slug":"d-ebda68","errorCode":null,"errorMessage":"响应超过 %d 字节","messagePattern":"响应超过 (.+?) 字节","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/xiaokupan/xiaokupan.go","lineNumber":194,"sourceCode":"\treq.Header.Set(\"x-tsr-serverFn\", \"true\")\n}\n\nfunc doLimitedRequest(client *http.Client, req *http.Request, limit int64) ([]byte, error) {\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"请求失败: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"HTTP %d\", resp.StatusCode)\n\t}\n\n\tbody, err := io.ReadAll(io.LimitReader(resp.Body, limit+1))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"读取响应失败: %w\", err)\n\t}\n\tif int64(len(body)) > limit {\n\t\treturn nil, fmt.Errorf(\"响应超过 %d 字节\", limit)\n\t}\n\treturn body, nil\n}\n\nfunc (p *XiaokupanPlugin) currentServerFunctionID() string {\n\tp.serverFunctionMu.RLock()\n\tdefer p.serverFunctionMu.RUnlock()\n\treturn p.serverFunctionID\n}\n\nfunc (p *XiaokupanPlugin) refreshServerFunctionID(client *http.Client, staleID string) (string, error) {\n\tp.serverFunctionMu.Lock()\n\tdefer p.serverFunctionMu.Unlock()\n\tif p.serverFunctionID != \"\" && p.serverFunctionID != staleID {\n\t\treturn p.serverFunctionID, nil\n\t}\n\n\tdiscoveredID, err := p.discoverServerFunctionID(client)","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/xiaokupan/xiaokupan.go#L176-L212","documentation":"Returned by doLimitedRequest when the response body exceeds the configured size limit (maxSearchResponseSize = 4MiB for search, maxDiscoveryBodySize = 8MiB for discovery). The LimitReader reads limit+1 bytes, so a body longer than the cap is detected and rejected to protect memory from runaway upstream responses.","triggerScenarios":"The xiaokupan search response exceeds 4MiB (e.g. a very broad keyword returning an enormous result set), or the homepage/entry JS bundle fetched during function-ID discovery exceeds 8MiB (site switched to a much larger bundle or began serving an unexpected page, like a giant error/captcha page).","commonSituations":"Searching an extremely common keyword returns a huge merged result payload; the site's build pipeline outputs index JS >8MiB; the site starts serving a bloated interstitial page instead of the expected content.","solutions":["Use a more specific keyword so the upstream returns a smaller result set","If legitimate responses are being cut off, raise maxSearchResponseSize (trade-off: memory per in-flight request)","If discovery triggers it, check what the homepage actually serves now — an unexpected page means the bundle/layout changed","Keep the limit as a guardrail; prefer fixing the query over disabling the cap"],"exampleFix":"// before\nmaxSearchResponseSize = 4 << 20\n// after: raise cap and log when exceeded\nmaxSearchResponseSize = 8 << 20\nif int64(len(body)) > limit {\n    return nil, fmt.Errorf(\"response exceeds %d bytes\", limit)\n}","handlingStrategy":"validation","validationCode":"// use a specific keyword to keep upstream result sets small\nif len(keyword) < 3 {\n    return errors.New(\"keyword too broad; expected oversized response, refine the query\")\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"响应超过\") || strings.Contains(err.Error(), \"字节\") {\n    // oversized response: refine keyword or raise the size cap\n    return refineQuery(keyword)\n}","preventionTips":["Prefer narrow, specific search keywords over very common ones","Raise maxSearchResponseSize only if legitimate payloads genuinely exceed 4MiB","Keep maxDiscoveryBodySize (8MiB) in sync with the site's real bundle size"],"tags":["http","limit","response-size"],"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"}