bug: DuckDuckGo searchPage.GetResults() cannot report errors #6

Closed
opened 2026-02-14 16:05:44 +00:00 by Claude · 3 comments
Collaborator

Parent: #1

Description

In sites/duckduckgo/page.go:20-57, GetResults() calls s.doc.ForEach() but the error is stored in a local variable and never returned. The method signature is GetResults() []Result — it has no error return value.

func (s searchPage) GetResults() []Result {
    var res []Result
    var err error

    err = s.doc.ForEach(`article[id^="r1-"]`, func(n extractor.Node) error {
        // ... extraction ...
    })

    return res // err is silently discarded
}

This means any ForEach errors during pagination or "Load More" are silently swallowed.

Fix

Change signature to GetResults() ([]Result, error) and return the error. This is a breaking API change for the SearchPage interface.

**Parent:** #1 ## Description In `sites/duckduckgo/page.go:20-57`, `GetResults()` calls `s.doc.ForEach()` but the error is stored in a local variable and never returned. The method signature is `GetResults() []Result` — it has no error return value. ```go func (s searchPage) GetResults() []Result { var res []Result var err error err = s.doc.ForEach(`article[id^="r1-"]`, func(n extractor.Node) error { // ... extraction ... }) return res // err is silently discarded } ``` This means any ForEach errors during pagination or "Load More" are silently swallowed. ## Fix Change signature to `GetResults() ([]Result, error)` and return the error. This is a breaking API change for the `SearchPage` interface.
Claude added the bugpriority/hightype/task labels 2026-02-14 16:06:14 +00:00
Author
Collaborator

Starting work on this as part of PR 4 (also includes #5). Will update SearchPage.GetResults() to return ([]Result, error) so the ForEach error is no longer silently discarded.

Starting work on this as part of PR 4 (also includes #5). Will update `SearchPage.GetResults()` to return `([]Result, error)` so the `ForEach` error is no longer silently discarded.
Author
Collaborator

Work finished. PR: #35

Changed SearchPage.GetResults() to return ([]Result, error) and propagate the ForEach error.

Work finished. PR: #35 Changed `SearchPage.GetResults()` to return `([]Result, error)` and propagate the `ForEach` error.
Author
Collaborator

Resolved by PR #35GetResults() now returns ([]Result, error) and Search() properly propagates errors.

Resolved by PR #35 — `GetResults()` now returns `([]Result, error)` and `Search()` properly propagates errors.
Sign in to join this conversation.