From 2b3f6214505182c34ac09880d1a2d7b03c204734 Mon Sep 17 00:00:00 2001 From: Woravit Ariyakunatorn Date: Sat, 21 Mar 2026 13:21:10 +0700 Subject: [PATCH] fix: handle JSON decode error in monocular search The return value of json.NewDecoder().Decode() was not being checked, so malformed responses from the search API would silently return empty results instead of reporting an error. Signed-off-by: Woravit Ariyakunatorn --- internal/monocular/search.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/monocular/search.go b/internal/monocular/search.go index fcf04b7a4..badbaac20 100644 --- a/internal/monocular/search.go +++ b/internal/monocular/search.go @@ -135,7 +135,9 @@ func (c *Client) Search(term string) ([]SearchResult, error) { result := &searchResponse{} - json.NewDecoder(res.Body).Decode(result) + if err := json.NewDecoder(res.Body).Decode(result); err != nil { + return nil, fmt.Errorf("failed to decode response from %s: %w", p.String(), err) + } return result.Data, nil }