bug: DuckDuckGo Search() discards ForEach error #5

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

Parent: #1

Description

In sites/duckduckgo/duckduckgo.go:88-133, the Search() method stores the error from doc.ForEach() in err (line 101) but then returns res, nil on line 133 instead of res, err.

func (c Config) Search(ctx context.Context, b extractor.Browser, query string) ([]Result, error) {
    // ...
    err = doc.ForEach(`article[id^="r1-"]`, func(n extractor.Node) error {
        // ... extraction logic ...
    })

    return res, nil // BUG: should be `return res, err`
}

If ForEach encounters an error while parsing results, the caller silently gets a partial result set with a nil error.

Fix

Change line 133 from return res, nil to return res, err.

**Parent:** #1 ## Description In `sites/duckduckgo/duckduckgo.go:88-133`, the `Search()` method stores the error from `doc.ForEach()` in `err` (line 101) but then returns `res, nil` on line 133 instead of `res, err`. ```go func (c Config) Search(ctx context.Context, b extractor.Browser, query string) ([]Result, error) { // ... err = doc.ForEach(`article[id^="r1-"]`, func(n extractor.Node) error { // ... extraction logic ... }) return res, nil // BUG: should be `return res, err` } ``` If `ForEach` encounters an error while parsing results, the caller silently gets a partial result set with a nil error. ## Fix Change line 133 from `return res, nil` to `return res, err`.
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 #6). Will fix Search() to return res, err and update GetResults() interface to return ([]Result, error).

Starting work on this as part of PR 4 (also includes #6). Will fix `Search()` to return `res, err` and update `GetResults()` interface to return `([]Result, error)`.
Author
Collaborator

Work finished. PR: #35

Fixed Search() to return res, err instead of res, nil.

Work finished. PR: #35 Fixed `Search()` to return `res, err` instead of `res, nil`.
Sign in to join this conversation.