Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

ProductBarcode: backend: properly check barcodespider API response

Crumb Owl94e81809d33e
diff --git a/backend/app/api/handlers/v1/v1_ctrl_product_search.go b/backend/app/api/handlers/v1/v1_ctrl_product_search.go
index dd0412a2..6e5c3978 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_product_search.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_product_search.go
@@ -194,6 +194,10 @@ func (ctrl *V1Controller) HandleProductSearchFromBarcode(conf config.BarcodeAPIC
}
defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ return nil, fmt.Errorf("barcodespider API returned status code: %d", resp.StatusCode)
+ }
+
// We Read the response body on the line below.
body, err := io.ReadAll(resp.Body)
if err != nil {