fish2018/pansou · error

[quarkres] decode response failed

Error message

[quarkres] decode response failed: %w

What it means

Wrapped decode error in quarkres' doSearch (plugin/quarkres/quarkres.go:110): the body downloaded but did not unmarshal into the apiResp struct — the endpoint returned non-JSON content (challenge/error page or changed schema).

Solutions

  1. 记录原始响应体确认实际内容
  2. 对照 API 更新 apiResp 结构
  3. 解析前校验 Content-Type
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at plugin/quarkres/quarkres.go:110 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at plugin/quarkres/quarkres.go:110

	resp, err := client.Do(req)
	if err != nil {
		return nil, fmt.Errorf("[quarkres] request failed: %w", err)
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("[quarkres] HTTP %d", resp.StatusCode)
	}

	bodyBytes, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, fmt.Errorf("[quarkres] read response failed: %w", err)
	}

	var ar apiResp
	if err := json.Unmarshal(bodyBytes, &ar); err != nil {
		return nil, fmt.Errorf("[quarkres] decode response failed: %w", err)
	}

	if ar.Code != 200 {
		return nil, fmt.Errorf("[quarkres] API error: %s", ar.Message)
	}

	results := make([]model.SearchResult, 0, len(ar.Data))
	for _, item := range ar.Data {
		links := make([]model.Link, 0, len(item.Links))
		for _, l := range item.Links {
			// 只保留夸克链接(本源只有夸克)
			if strings.Contains(l.URL, "pan.quark.cn") {
				links = append(links, model.Link{
					Type:     "quark",
					URL:      l.URL,
					Password: l.Password,
					Datetime: item.Datetime,
				})

View on GitHub (pinned to beaa561337)