{"record":{"id":"1e552f30d0c94e3f","repo":"fish2018/pansou","slug":"w-1e552f","errorCode":null,"errorMessage":"读取首页失败: %w","messagePattern":"读取首页失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/xiaokupan/xiaokupan.go","lineNumber":233,"sourceCode":"\t}\n\tp.serverFunctionID = discoveredID\n\treturn discoveredID, nil\n}\n\nfunc (p *XiaokupanPlugin) discoverServerFunctionID(client *http.Client) (string, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), requestTimeout)\n\tdefer cancel()\n\n\thomeURL := strings.TrimRight(p.baseURL, \"/\") + \"/\"\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, homeURL, nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treq.Header.Set(\"User-Agent\", \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36\")\n\treq.Header.Set(\"Accept\", \"text/html,application/xhtml+xml\")\n\thomeBody, err := doLimitedRequest(client, req, maxDiscoveryBodySize)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"读取首页失败: %w\", err)\n\t}\n\n\tassetPath := string(indexAssetPattern.Find(homeBody))\n\tif assetPath == \"\" {\n\t\treturn \"\", fmt.Errorf(\"首页未找到入口脚本\")\n\t}\n\tassetReq, err := http.NewRequestWithContext(ctx, http.MethodGet, strings.TrimRight(p.baseURL, \"/\")+assetPath, nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tassetReq.Header.Set(\"User-Agent\", req.Header.Get(\"User-Agent\"))\n\tassetReq.Header.Set(\"Referer\", homeURL)\n\tassetBody, err := doLimitedRequest(client, assetReq, maxDiscoveryBodySize)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"读取入口脚本失败: %w\", err)\n\t}\n\n\trouteIndex := strings.Index(string(assetBody), \"/s/$query\")","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/xiaokupan/xiaokupan.go#L215-L251","documentation":"Wraps any error from doLimitedRequest while fetching the xiaokupan homepage (https://xiaokupan.com/) inside discoverServerFunctionID. Discovery is the fallback path used when the cached server-function ID fails, so this error means the recovery step itself could not even download the homepage HTML needed to locate the entry JS asset.","triggerScenarios":"Homepage fetch fails via doLimitedRequest: network error (请求失败 wrapper), non-200 status (HTTP NNN wrapper), mid-body read failure, or homepage body exceeding maxDiscoveryBodySize (8MiB). Triggered when searchImpl detects a stale/broken function ID and calls refreshServerFunctionID -> discoverServerFunctionID.","commonSituations":"Site down or DNS unreachable at the moment of recovery; Cloudflare/WAF blocking the programmatic homepage request (403); homepage served a 5xx during maintenance; very slow homepage load hitting the 30s timeout.","solutions":["Check the wrapped cause: 请求失败 → connectivity, HTTP 403 → anti-bot, HTTP 5xx → site down, timeout → slow site","Verify with curl -v https://xiaokupan.com/ that the homepage is reachable from the host","For 403, update request headers (User-Agent/Accept already set) or resolve IP blocking with the site","Note the cached functionID remains in use until discovery succeeds — fix connectivity so future refreshes can run","Retry later if the site is under maintenance"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"resp, err := http.Head(\"https://xiaokupan.com/\")\nif err != nil || resp.StatusCode != http.StatusOK {\n    return errors.New(\"xiaokupan homepage unreachable; discovery will fail\")\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"读取首页失败\") {\n    // recovery path failed at the very first step; keep cached functionID\n    // and fall back to other search sources\n    return fallbackSearch(keyword)\n}","preventionTips":["Health-check the homepage before relying on this plugin","Keep the cached defaultServerFunctionID valid so discovery is rarely needed","Ensure stable egress and browser-like headers to survive the site's WAF"],"tags":["network","http","discovery"],"backgroundTag":"http-request-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"}