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:
wangyanfu2
2026-03-03 17:50:29 +08:00
parent de2ccb5da4
commit 7de4cc5ebd
+4
View File
@@ -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 {