{"record":{"id":"f55e7c36f9bc54b7","repo":"fish2018/pansou","slug":"web-search-returned-no-document-items","errorCode":null,"errorMessage":"web search returned no document items","messagePattern":"web search returned no document items","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/sousou/sousou.go","lineNumber":212,"sourceCode":"\n\titems := make([]pansoSearchItem, 0, 20)\n\tdoc.Find(\"div.search-item\").Each(func(_ int, item *goquery.Selection) {\n\t\tanchor := item.Find(\"a.search-item-title[href]\").First()\n\t\thref := strings.TrimSpace(anchor.AttrOr(\"href\", \"\"))\n\t\tif href == \"\" {\n\t\t\treturn\n\t\t}\n\t\titems = append(items, pansoSearchItem{\n\t\t\tDocURL:   absolutePansoURL(href),\n\t\t\tTitle:    strings.TrimSpace(anchor.Text()),\n\t\t\tContent:  strings.TrimSpace(item.Find(\".search-item-info\").Text()),\n\t\t\tDiskType: strings.TrimSpace(item.Find(\".search-item-logo\").AttrOr(\"alt\", \"\")),\n\t\t\tDatetime: parsePansoDatetime(item.Find(\".search-item-meta-item\").Text()),\n\t\t\tPassword: parsePansoPassword(item),\n\t\t})\n\t})\n\tif len(items) == 0 {\n\t\treturn nil, fmt.Errorf(\"web search returned no document items\")\n\t}\n\n\tresults := make([]model.SearchResult, 0, len(items))\n\tsem := make(chan struct{}, 8)\n\tvar wg sync.WaitGroup\n\tvar mu sync.Mutex\n\tfor _, item := range items {\n\t\titem := item\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tsem <- struct{}{}\n\t\t\tdefer func() { <-sem }()\n\t\t\tresult, err := p.fetchPansoDocument(client, item)\n\t\t\tif err != nil {\n\t\t\t\tdebugLog(\"document %s failed: %v\", item.DocURL, err)\n\t\t\t\treturn\n\t\t\t}","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/sousou/sousou.go#L194-L230","documentation":"After parsing the panso search page, searchWeb expects to extract items matching div.search-item. If zero items are found it raises 'web search returned no document items' instead of returning an empty result. This detects silent upstream layout changes or a page that is no longer a results page.","triggerScenarios":"doc.Find(\"div.search-item\") matched nothing in searchWeb — the page rendered but contained no results blocks, e.g. a captcha/consent page, an empty keyword result with different markup, or a CSS selector that no longer matches after a site redesign.","commonSituations":"panso.vip redesigned its search results DOM; search returned a 'no results' page with different structure; anti-bot interstitial served with 200; keyword genuinely has no matches.","solutions":["Fetch the URL manually and diff the DOM against the div.search-item selector; update the selector.","Check whether the keyword has no real results and distinguish that from a layout change before erroring.","Inspect the HTML for captcha/challenge markers and handle that case explicitly.","Verify the response is the search results page and not a redirect to a homepage."],"exampleFix":"// before\nif len(items) == 0 {\n    return nil, fmt.Errorf(\"web search returned no document items\")\n}\n// after\nif len(items) == 0 {\n    if doc.Find(\".no-result\").Length() > 0 {\n        return []model.SearchResult{}, nil // genuine empty result\n    }\n    return nil, fmt.Errorf(\"web search returned no document items\")\n}","handlingStrategy":"validation","validationCode":"// sanity check after parse\nif doc.Find(\"div.search-item\").Length() == 0 && doc.Find(\".no-result\").Length() == 0 {\n    // neither results nor an empty-state marker: likely layout change or bot page\n}","typeGuard":null,"tryCatchPattern":"results, err := plugin.Search(keyword)\nif err != nil && strings.Contains(err.Error(), \"no document items\") {\n    // distinguish genuine empty results from broken selectors before retrying\n}","preventionTips":["Pin CSS selectors in config/tests and verify them with periodic smoke tests","Detect 'no results' UI states separately from zero matched selectors","Log raw HTML when selectors match nothing to speed up diagnosis","Test with multiple keywords including ones known to have results"],"tags":["scraping","css-selectors","layout-change","go"],"backgroundTag":"empty-api-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"}