{"record":{"id":"53856e5e59e3676f","repo":"fish2018/pansou","slug":"s-code-d-msg-s-53856e","errorCode":null,"errorMessage":"[%s] 搜索接口异常: code=%d msg=%s","messagePattern":"\\[(.+?)\\] 搜索接口异常: code=(.+?) msg=(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/yingso/yingso.go","lineNumber":230,"sourceCode":"\t\tPageSize: pageSize,\n\t\tPageNum:  1,\n\t\tTitle:    keyword,\n\t\tRoot:     0,\n\t\tCategory: \"all\",\n\t\tUserID:   config.UserID,\n\t}\n\tencrypted, err := encryptPayload(payload, config)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 生成搜索参数失败: %w\", p.Name(), err)\n\t}\n\n\tvar response apiEnvelope[[]searchItem]\n\tendpoint := fmt.Sprintf(\"%s/%s/search\", p.apiBaseURL, url.PathEscape(config.URLVersion))\n\tif err := p.requestJSON(ctx, client, http.MethodPost, endpoint, encrypted, &response); err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索请求失败: %w\", p.Name(), err)\n\t}\n\tif response.Code != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索接口异常: code=%d msg=%s\", p.Name(), response.Code, response.Msg)\n\t}\n\treturn response.Data, nil\n}\n\nfunc (p *YingsoPlugin) resolveItem(ctx context.Context, client *http.Client, config apiConfig, item searchItem) (model.SearchResult, error) {\n\tpayload := getKeyPayload{ID: item.ID, UserID: config.UserID}\n\tencrypted, err := encryptPayload(payload, config)\n\tif err != nil {\n\t\treturn model.SearchResult{}, err\n\t}\n\n\tvar response apiEnvelope[string]\n\tendpoint := fmt.Sprintf(\"%s/%s/getKey\", p.apiBaseURL, url.PathEscape(config.URLVersion))\n\tif err := p.requestJSON(ctx, client, http.MethodPost, endpoint, encrypted, &response); err != nil {\n\t\treturn model.SearchResult{}, err\n\t}\n\tif response.Code != http.StatusOK || strings.TrimSpace(response.Data) == \"\" {\n\t\treturn model.SearchResult{}, fmt.Errorf(\"getKey id=%d code=%d msg=%s\", item.ID, response.Code, response.Msg)","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/yingso/yingso.go#L212-L248","documentation":"This error is returned by YingsoPlugin.search when the Yingso /search endpoint responds with a valid JSON envelope whose code field is not 200. The HTTP request itself succeeded and the body parsed, but the Yingso API rejected the search request; the API's own code and msg are surfaced for diagnosis.","triggerScenarios":"POST to {apiBaseURL}/{url_version}/search returns apiEnvelope with code != 200, e.g. the encrypted payload uses a stale url_version/user_id from fetchConfig, the keyword is rejected/filtered by the API, the API is rate limiting, or the XOR-encrypted request parameters are considered invalid by the server.","commonSituations":"The Yingso API rotated its url_version so the encrypted payload no longer validates server-side; transient upstream throttling during heavy search load; the API changed its envelope codes; the bootstrap config (user_id) became stale or blocked.","solutions":["Log response.Code and response.Msg from the error to identify the API's stated reason and match it against the Yingso API contract.","Re-fetch the bootstrap config (fetchConfig /test) — a stale url_version or user_id is the most common cause — and retry the search.","Retry the request after a short backoff; code values like 429 or 5xx in the envelope indicate transient throttling or upstream trouble.","Verify the request payload matches the current Yingso searchPayload schema; if the API changed fields, update searchPayload/encryptPayload.","If the API is permanently rejecting requests (e.g. endpoint deprecated), disable the yingso plugin or update defaultAPIBaseURL."],"exampleFix":"// before\nif response.Code != http.StatusOK {\n\treturn nil, fmt.Errorf(\"[%s] 搜索接口异常: code=%d msg=%s\", p.Name(), response.Code, response.Msg)\n}\n// after\nif response.Code != http.StatusOK {\n\tif response.Code == http.StatusTooManyRequests {\n\t\t// retry with backoff before giving up\n\t\treturn p.search(ctx, client, config, keyword)\n\t}\n\treturn nil, fmt.Errorf(\"[%s] 搜索接口异常: code=%d msg=%s\", p.Name(), response.Code, response.Msg)\n}","handlingStrategy":"retry","validationCode":"if code, msg := yingsoProbeSearch(client); code != 200 {\n\tlog.Printf(\"yingso unavailable: code=%d msg=%s\", code, msg)\n}","typeGuard":null,"tryCatchPattern":"results, err := plugin.Search(keyword, ext)\nif err != nil {\n\tvar apiErr string\n\tif strings.Contains(err.Error(), \"搜索接口异常\") {\n\t\tapiErr = \"yingso api rejected request; re-fetching config and retrying\"\n\t}\n\tlog.Println(apiErr, err)\n\ttime.Sleep(backoff)\n\tresults, err = plugin.Search(keyword, ext)\n}","preventionTips":["Call fetchConfig fresh before searching so url_version/user_id are current.","Wrap searches in retry with backoff for transient API codes.","Monitor the error's code=%d value and alert on systematic changes (API contract drift).","Respect any rate limits; avoid hammering the search endpoint."],"tags":["http","api","upstream","search"],"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"}