From 689562a2f1ce30b73c18074efedb4ebb36d67484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Comb=C3=BCchen?= Date: Fri, 19 Jul 2024 08:58:47 +0200 Subject: [PATCH] fix: handle unsuccessful Snyk API responses (#70) --- lib/snyk/package.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/snyk/package.go b/lib/snyk/package.go index 5037ddc..61f4c24 100644 --- a/lib/snyk/package.go +++ b/lib/snyk/package.go @@ -18,6 +18,8 @@ package snyk import ( "context" + "fmt" + "net/http" "github.com/deepmap/oapi-codegen/pkg/securityprovider" "github.com/google/uuid" @@ -96,5 +98,9 @@ func GetPackageVulnerabilities(purl *packageurl.PackageURL, auth *securityprovid return nil, err } + if resp.StatusCode() != http.StatusOK { + return resp, fmt.Errorf("unsuccessful request (%s)", resp.Status()) + } + return resp, nil }