Merge pull request #3141 from jincheng-xydt/fix/3125-brave-search-logging
fix(web_search): add diagnostic logging for Brave empty results
This commit is contained in:
commit
99291182e7
1 changed files with 13 additions and 0 deletions
|
|
@ -350,6 +350,19 @@ func (p *BraveSearchProvider) Search(
|
|||
|
||||
results := searchResp.Web.Results
|
||||
if len(results) == 0 {
|
||||
// Log a warning when the API returned 200 but no results.
|
||||
// This helps diagnose API format changes or silent errors
|
||||
// where the response body does not match the expected structure.
|
||||
bodyPreview := string(body)
|
||||
if len(bodyPreview) > 300 {
|
||||
bodyPreview = bodyPreview[:300]
|
||||
}
|
||||
logger.WarnCF("web_search", "Brave API returned empty results",
|
||||
map[string]any{
|
||||
"query": query,
|
||||
"status": resp.StatusCode,
|
||||
"body_preview": bodyPreview,
|
||||
})
|
||||
return fmt.Sprintf("No results for: %s", query), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue