fish2018/pansou · error
API returned error
Error message
API returned error: %s
What it means
API-level error in jikepan's doSearch (plugin/jikepan/jikepan.go:102): the JSON decoded correctly but the response's Msg field is not "success", so the API itself reported a failure; the actual message is carried in the error text.
Solutions
- Log apiResp.Msg and apiResp.Code to see the exact upstream reason
- Compare against a set of accepted success values or check a code field instead of a hardcoded string
- Verify the request body matches the current API contract (keyword, is_all, pagination)
- Check jikepan.xyz service status / account quota
Example fix
// before
if apiResp.Msg != "success" {
return nil, fmt.Errorf("API returned error: %s", apiResp.Msg)
}
// after
if apiResp.Code != 0 && apiResp.Msg != "success" {
return nil, fmt.Errorf("API returned error (code=%d): %s", apiResp.Code, apiResp.Msg)
} Defensive patterns
Strategy: try-catch
Try / catch
// Go
results, err := p.doSearch(ctx, keyword, ext)
if err != nil {
if strings.HasPrefix(err.Error(), "API returned error:") {
log.Printf("jikepan business error: %v", err)
return nil, plugin.ErrUpstreamRejected
}
return nil, err
} Prevention
- Log msg (and any code field) from every response
- Treat non-success msg as upstream, not local, failure
- Track API contract changes
- Handle quota/auth-style messages distinctly
When it happens
Trigger: The Jikepan API responds with valid JSON whose msg field is not exactly "success" — e.g. quota exhausted, invalid token/params, or empty query handled server-side.
Common situations: API 端点升级后返回新的错误码;请求频率触发配额限制。
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/b8529549ae38942c.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/jikepan/jikepan.go:102
if err != nil {
return nil, fmt.Errorf("request failed: %w", err)
}
defer resp.Body.Close()
// 解析响应
var apiResp JikepanResponse
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read response body failed: %w", err)
}
if err := json.Unmarshal(bodyBytes, &apiResp); err != nil {
return nil, fmt.Errorf("decode response failed: %w", err)
}
// 检查响应状态
if apiResp.Msg != "success" {
return nil, fmt.Errorf("API returned error: %s", apiResp.Msg)
}
// 转换结果格式
results := p.convertResults(apiResp.List)
return results, nil
}
// convertResults 将API响应转换为标准SearchResult格式
func (p *JikepanAsyncV2Plugin) convertResults(items []JikepanItem) []model.SearchResult {
results := make([]model.SearchResult, 0, len(items))
for i, item := range items {
// 跳过没有链接的结果
if len(item.Links) == 0 {
continue
}
View on GitHub (pinned to beaa561337)