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:
1 parent
de2ccb5da4
commit
7de4cc5ebd
1 file changed
+4
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user