From 7de4cc5ebde197bd89b3ba9e1ad772797ac8abfe Mon Sep 17 00:00:00 2001 From: wangyanfu2 Date: Tue, 3 Mar 2026 17:50:29 +0800 Subject: [PATCH] fix: add HTTP status code check in BraveSearchProvider - Add status code validation after reading response body, consistent with TavilySearchProvider and PerplexitySearchProvider --- pkg/tools/web.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/tools/web.go b/pkg/tools/web.go index 10498126b6..15d2330ffa 100644 --- a/pkg/tools/web.go +++ b/pkg/tools/web.go @@ -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 {