mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-07-28 01:27:58 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user