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(cConfig)Search(ctxcontext.Context,bextractor.Browser,querystring)([]Result,error){// ...err=doc.ForEach(`article[id^="r1-"]`,func(nextractor.Node)error{// ... extraction logic ...})returnres,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`.
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)`.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent: #1
Description
In
sites/duckduckgo/duckduckgo.go:88-133, theSearch()method stores the error fromdoc.ForEach()inerr(line 101) but then returnsres, nilon line 133 instead ofres, err.If
ForEachencounters an error while parsing results, the caller silently gets a partial result set with a nil error.Fix
Change line 133 from
return res, niltoreturn res, err.Starting work on this as part of PR 4 (also includes #6). Will fix
Search()to returnres, errand updateGetResults()interface to return([]Result, error).Work finished. PR: #35
Fixed
Search()to returnres, errinstead ofres, nil.