fish2018/pansou · error

[ ] 搜索接口返回异常: success= code=

Error message

[%s] 搜索接口返回异常: success=%v code=%d

What it means

The getVideoList JSON parsed fine but the logical envelope check failed: either resp.Success was false or resp.Code was not HTTP 200. The API itself reported an error condition, so fetchSearchItems aborts with the success flag and code included for diagnosis.

Solutions

  1. Log the full response body when success=false to read the API's error message field
  2. Verify lingjiIdentity, keyword encoding, and other query params match the current API contract
  3. Add retry with backoff for transient upstream errors (rate limiting)
  4. Update the plugin if the API changed its success/code semantics
  5. Check whether the API requires auth headers or cookies that have expired
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate request params the API is known to reject
if keyword == "" || lingjiIdentity == "" {
    return fmt.Errorf("搜索参数缺失: keyword/identity")
}

Try / catch

items, err := fetchSearchItems(...)
var apiErr *LingjiAPIError
if errors.As(err, &apiErr) {
    log.Printf("lingjisp 上游拒绝: success=%v code=%d", apiErr.Success, apiErr.Code)
    if apiErr.Code == http.StatusTooManyRequests {
        time.Sleep(cooldown)
        // retry once
    }
    return emptyResults, nil
}

Prevention

When it happens

Trigger: JSON body matched lingjiSearchResponse but the payload said success=false or code != 200 — e.g. invalid/missing parameters, API key/identity rejected, rate limited by the upstream API, or empty/invalid search keyword handling server-side.

Common situations: lingjiIdentity or other query params are stale/invalid after an API update; upstream throttling returns coded errors; keyword rejected by server-side validation; API moved to a new error-code scheme.

Related errors


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/ac209d9f9dc441bb. Report an issue: GitHub.

Appendix: source

Thrown at plugin/lingjisp/lingjisp.go:202

	params := url.Values{}
	params.Set("app_id", lingjiAppID)
	params.Set("identity", lingjiIdentity)
	params.Set("sb", keyword)
	params.Set("page", "1")
	params.Set("limit", "20")

	apiURL := lingjiAPIBase + "getVideoList?" + params.Encode()
	body, err := doLingjiGET(client, apiURL, lingjiSearchTimeout)
	if err != nil {
		return nil, fmt.Errorf("[%s] 搜索请求失败: %w", p.Name(), err)
	}

	var resp lingjiSearchResponse
	if err := json.Unmarshal(body, &resp); err != nil {
		return nil, fmt.Errorf("[%s] 解析搜索响应失败: %w", p.Name(), err)
	}
	if !resp.Success || resp.Code != http.StatusOK {
		return nil, fmt.Errorf("[%s] 搜索接口返回异常: success=%v code=%d", p.Name(), resp.Success, resp.Code)
	}

	items := resp.Data.Data
	if len(items) == 0 {
		items = resp.Data.List
	}
	return dedupeLingjiItems(items), nil
}

func (p *LingjiPlugin) fetchDetail(client *http.Client, doubID int) (lingjiVideoItem, error) {
	params := url.Values{}
	params.Set("app_id", lingjiAppID)
	params.Set("identity", lingjiIdentity)
	params.Set("id", fmt.Sprintf("%d", doubID))

	apiURL := lingjiAPIBase + "getVideoDetail?" + params.Encode()
	body, err := doLingjiGET(client, apiURL, lingjiDetailTimeout)
	if err != nil {

View on GitHub (pinned to beaa561337)