fix(engines): cap Brave API offset to 9 to avoid 422 error
Brave API only supports offset values 0-9. When pageno > 1 with resultsPerPage=20, offset exceeded this limit causing 422 errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3bc1fad6b5
commit
f172da33ef
1 changed files with 5 additions and 0 deletions
|
|
@ -80,10 +80,15 @@ func (e *BraveEngine) Search(ctx context.Context, req contracts.SearchRequest) (
|
|||
return contracts.SearchResponse{Query: req.Query}, nil
|
||||
}
|
||||
|
||||
// Brave API only supports offset values 0-9 (first page of results).
|
||||
// Paginating beyond the first page is not supported by Brave.
|
||||
offset := 0
|
||||
if req.Pageno > 1 {
|
||||
offset = (req.Pageno - 1) * e.resultsPerPage
|
||||
}
|
||||
if offset > 9 {
|
||||
offset = 9
|
||||
}
|
||||
|
||||
args := url.Values{}
|
||||
args.Set("q", q)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue