{"record":{"id":"6e078956f26f4e31","repo":"fish2018/pansou","slug":"s-success-v-code-d-6e0789","errorCode":null,"errorMessage":"[%s] 详情接口返回异常: success=%v code=%d","messagePattern":"\\[(.+?)\\] 详情接口返回异常: success=(.+?) code=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/lingjisp/lingjisp.go","lineNumber":229,"sourceCode":"\nfunc (p *LingjiPlugin) fetchDetail(client *http.Client, doubID int) (lingjiVideoItem, error) {\n\tparams := url.Values{}\n\tparams.Set(\"app_id\", lingjiAppID)\n\tparams.Set(\"identity\", lingjiIdentity)\n\tparams.Set(\"id\", fmt.Sprintf(\"%d\", doubID))\n\n\tapiURL := lingjiAPIBase + \"getVideoDetail?\" + params.Encode()\n\tbody, err := doLingjiGET(client, apiURL, lingjiDetailTimeout)\n\tif err != nil {\n\t\treturn lingjiVideoItem{}, fmt.Errorf(\"[%s] 详情请求失败: %w\", p.Name(), err)\n\t}\n\n\tvar resp lingjiDetailResponse\n\tif err := json.Unmarshal(body, &resp); err != nil {\n\t\treturn lingjiVideoItem{}, fmt.Errorf(\"[%s] 解析详情响应失败: %w\", p.Name(), err)\n\t}\n\tif !resp.Success || resp.Code != http.StatusOK {\n\t\treturn lingjiVideoItem{}, fmt.Errorf(\"[%s] 详情接口返回异常: success=%v code=%d\", p.Name(), resp.Success, resp.Code)\n\t}\n\treturn resp.Data, nil\n}\n\nfunc doLingjiGET(client *http.Client, requestURL string, timeout time.Duration) ([]byte, error) {\n\tvar lastErr error\n\n\tfor attempt := 0; attempt < lingjiMaxRetries; attempt++ {\n\t\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\t\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, requestURL, nil)\n\t\tif err != nil {\n\t\t\tcancel()\n\t\t\treturn nil, err\n\t\t}\n\n\t\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\t\treq.Header.Set(\"Accept\", \"application/json,text/plain,*/*\")\n\t\treq.Header.Set(\"Accept-Language\", \"zh-CN,zh;q=0.9,en;q=0.8\")","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/lingjisp/lingjisp.go#L211-L247","documentation":"The getVideoDetail JSON parsed but the envelope check failed: resp.Success was false or resp.Code was not 200, so fetchDetail aborts reporting both values. The upstream API explicitly signaled an error for this detail request.","triggerScenarios":"Valid JSON from getVideoDetail whose success=false or code!=200 — typically id not found in the API's database, invalid/missing identity parameter, or upstream-side rate limiting/authorization failure.","commonSituations":"Requested douban id doesn't exist upstream (record-not-found from the API); lingjiIdentity stale after API update; API throttles bursts of detail lookups during scraping; account/token requirements introduced by an API version change.","solutions":["Include the API's message field in the log to learn the exact upstream reason","Validate the doubID exists (via search results) before fetching details","Verify lingjiIdentity and other params against the current API docs","Add backoff for code values indicating throttling","Update the plugin if the API changed status-code semantics"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Only query ids that came from a successful search response\nif doubID <= 0 || !idFromSearchResults(doubID) {\n    return lingjiVideoItem{}, fmt.Errorf(\"跳过未知详情ID: %d\", doubID)\n}","typeGuard":null,"tryCatchPattern":"item, err := fetchDetail(doubID)\nvar apiErr *LingjiAPIError\nif errors.As(err, &apiErr) {\n    switch {\n    case apiErr.Code == http.StatusNotFound:\n        return emptyItem, nil // record genuinely not found upstream\n    case isThrottleCode(apiErr.Code):\n        time.Sleep(backoff)\n        return fetchDetail(doubID)\n    default:\n        return emptyItem, err\n    }\n}","preventionTips":["Treat code!=200 with the API's message field for root cause","Expect record-not-found for stale ids and skip gracefully","Back off on throttling codes instead of hammering","Re-verify lingjiIdentity after API updates"],"tags":["api","upstream","validation"],"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"}