{"record":{"id":"676180297dd7e439","repo":"fish2018/pansou","slug":"s-api-s-676180","errorCode":null,"errorMessage":"[%s] 搜索API返回错误: %s","messagePattern":"\\[(.+?)\\] 搜索API返回错误: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/xys/xys.go","lineNumber":284,"sourceCode":"\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索请求HTTP状态错误: %d\", p.Name(), resp.StatusCode)\n\t}\n\n\t// 读取响应体\n\trespBody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 读取响应体失败: %w\", p.Name(), err)\n\t}\n\n\t// 解析JSON响应\n\tvar searchResp SearchResponse\n\tif err := json.Unmarshal(respBody, &searchResp); err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] JSON解析失败: %w\", p.Name(), err)\n\t}\n\n\tif searchResp.Code != 0 {\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索API返回错误: %s\", p.Name(), searchResp.Msg)\n\t}\n\n\tif p.debugMode {\n\t\tlog.Printf(\"[XYS] 搜索API响应成功，data长度: %d\", len(searchResp.Data))\n\t}\n\n\t// 解析HTML内容\n\treturn p.parseSearchResults(searchResp.Data, keyword)\n}\n\n// parseSearchResults 解析搜索结果HTML\nfunc (p *XysPlugin) parseSearchResults(htmlData, keyword string) ([]model.SearchResult, error) {\n\tdoc, err := goquery.NewDocumentFromReader(strings.NewReader(htmlData))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 解析搜索结果HTML失败: %w\", p.Name(), err)\n\t}\n\n\tvar results []model.SearchResult","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/xys/xys.go#L266-L302","documentation":"After successfully parsing the JSON, executeSearch checks searchResp.Code != 0 and reports the upstream API's business-level error message (searchResp.Msg). The JSON was valid, but the XYS search API itself rejected or failed the request and returned a non-zero code.","triggerScenarios":"The XYS search endpoint returned valid JSON with a non-zero Code field — e.g. rate limiting, invalid/expired session cookies, blocked IP, or an invalid query — with the human-readable reason in Msg.","commonSituations":"Too many rapid searches triggering upstream rate limits; the search keyword triggered a server-side validation error; XYS backend maintenance or API contract changes; expired login cookies the plugin depends on.","solutions":["Inspect searchResp.Msg in the error message for the upstream reason and act accordingly.","If Msg indicates rate limiting, back off and slow the request rate.","Refresh cookies/credentials the plugin uses to authenticate with XYS.","Retry later if the upstream reports a transient internal error."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"results, err := search(keyword)\nif err != nil {\n    if strings.Contains(err.Error(), \"搜索API返回错误\") {\n        // upstream business error; back off and retry\n        time.Sleep(backoff)\n        return searchWithRetry(keyword, attempts-1)\n    }\n    return err\n}","preventionTips":["Throttle request rate to avoid upstream rate limits.","Keep authentication cookies/credentials fresh.","Monitor the upstream service status.","Surface searchResp.Msg to logs so the root cause is visible."],"tags":["api","http","upstream-error"],"backgroundTag":"api-error-response","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"}