fish2018/pansou · warning
no posts found
Error message
no posts found
What it means
Empty-result error in GetTopicDetail (plugin/discourse/discourse.go:500): the JSON parsed fine but PostStream.Posts is empty, so there is no post from which to extract pan links. Fires for topics that exist yet contain no posts the endpoint returned (empty or restricted topic).
Solutions
- Verify the topic actually has posts by opening it in a browser
- Check whether the topic requires login; authenticate the scraper session if so
- Update DetailResponse struct to match the forum's current Discourse API schema
- Treat as an empty result and skip the topic instead of failing hard
Example fix
// before
if len(detailResp.PostStream.Posts) == 0 {
return nil, fmt.Errorf("no posts found")
}
// after
if len(detailResp.PostStream.Posts) == 0 {
return nil, nil // empty topic; nothing to extract
} Defensive patterns
Strategy: fallback
Validate before calling
// check the topic has content before extracting links
resp, _ := http.Get(baseURL + "/t/" + id + ".json")
var probe struct{ PostsCount int `json:"posts_count"` }
json.NewDecoder(resp.Body).Decode(&probe)
if probe.PostsCount == 0 {
return nil // skip empty topic
} Type guard
func hasPosts(d DetailResponse) bool { return len(d.PostStream.Posts) > 0 } Try / catch
links, err := plugin.GetTopicDetail(id)
if err != nil {
if err.Error() == "no posts found" {
log.Printf("topic %d has no posts; skipping", id)
return nil, nil
}
return nil, err
} Prevention
- Skip topics with zero posts_count before fetching detail
- Authenticate when topics require login
- Keep DetailResponse fields in sync with the forum's Discourse version
When it happens
Trigger: Detail JSON parsed successfully but post_stream.posts array is empty — e.g. topic is empty/deleted, access restricted so posts are withheld, or the JSON shape changed so posts land elsewhere.
Common situations: 主题仅含标题无正文;API 返回了被审核删除后的空帖列表。
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/4dcce21fa9d7126f.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/discourse/discourse.go:500
if resp.StatusCode != 200 {
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
// 读取响应体
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read response failed: %w", err)
}
// 解析JSON响应
var detailResp DetailResponse
if err := json.Unmarshal(body, &detailResp); err != nil {
return nil, fmt.Errorf("parse json failed: %w", err)
}
// 提取第一个帖子的链接
if len(detailResp.PostStream.Posts) == 0 {
return nil, fmt.Errorf("no posts found")
}
mainPost := detailResp.PostStream.Posts[0]
// 从 link_counts 中提取网盘链接
var links []model.Link
for _, linkCount := range mainPost.LinkCounts {
// 跳过内部链接
if linkCount.Internal {
continue
}
// 判断是否为网盘链接并解析
link := p.parseNetDiskLink(linkCount.URL)
if link != nil {
links = append(links, *link)
}
}View on GitHub (pinned to beaa561337)