fix: add HTTP status code check in BraveSearchProvider
- Add status code validation after reading response body, consistent with TavilySearchProvider and PerplexitySearchProvider
This commit is contained in:
parent
de2ccb5da4
commit
7de4cc5ebd
1 changed files with 4 additions and 0 deletions
|
|
@ -109,6 +109,10 @@ func (p *BraveSearchProvider) Search(ctx context.Context, query string, count in
|
|||
return "", fmt.Errorf("failed to read response: %w", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", fmt.Errorf("brave api error (status %d): %s", resp.StatusCode, string(body))
|
||||
}
|
||||
|
||||
var searchResp struct {
|
||||
Web struct {
|
||||
Results []struct {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue