internal: don't report on vulndb errors

A 500 response from the vulndb is not actionable for pkgsite.
If vulndb is down, the uptime checks will alert the team.

Change-Id: I4bacf4cd30d1522c21228906a9b16fccc86ac106
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/451361
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
diff --git a/internal/derrors/derrors.go b/internal/derrors/derrors.go
index 4702ae5..ffc2325 100644
--- a/internal/derrors/derrors.go
+++ b/internal/derrors/derrors.go
@@ -64,6 +64,9 @@
 	// ProxyError is used to capture non-actionable server errors returned from the proxy.
 	ProxyError = errors.New("proxy error")
 
+	// VulnDBError is used to capture non-actionable server errors returned from vulndb.
+	VulnDBError = errors.New("vulndb error")
+
 	// PackageBuildContextNotSupported indicates that the build context for the
 	// package is not supported.
 	PackageBuildContextNotSupported = errors.New("package build context not supported")
@@ -131,6 +134,7 @@
 
 	{ProxyTimedOut, 550}, // not a real code
 	{ProxyError, 551},    // not a real code
+	{VulnDBError, 552},   // not a real code
 	// 52x and 54x errors represents modules that need to be reprocessed, and the
 	// previous status code the module had. Note that the status code
 	// matters for determining reprocessing order.
diff --git a/internal/frontend/vulns.go b/internal/frontend/vulns.go
index 57ea1bc..90aad1a 100644
--- a/internal/frontend/vulns.go
+++ b/internal/frontend/vulns.go
@@ -108,7 +108,7 @@
 func newVulnPage(ctx context.Context, client vulnc.Client, id string) (*VulnPage, error) {
 	entry, err := client.GetByID(ctx, id)
 	if err != nil {
-		return nil, err
+		return nil, derrors.VulnDBError
 	}
 	if entry == nil {
 		return nil, derrors.NotFound
@@ -136,7 +136,7 @@
 
 	ids, err := client.ListIDs(ctx)
 	if err != nil {
-		return nil, err
+		return nil, derrors.VulnDBError
 	}
 
 	entries := make([]OSVEntry, len(ids))
@@ -157,7 +157,7 @@
 		})
 	}
 	if err := g.Wait(); err != nil {
-		return nil, err
+		return nil, derrors.VulnDBError
 	}
 	return entries, nil
 }
diff --git a/internal/middleware/errorreporting.go b/internal/middleware/errorreporting.go
index 3e51989..8351e80 100644
--- a/internal/middleware/errorreporting.go
+++ b/internal/middleware/errorreporting.go
@@ -40,6 +40,10 @@
 			if w2.status == derrors.ToStatus(derrors.ProxyError) {
 				return
 			}
+			// Don't report on vulndb errors.
+			if w2.status == derrors.ToStatus(derrors.VulnDBError) {
+				return
+			}
 			report(errorreporting.Entry{
 				Error: fmt.Errorf("handler for %q returned status code %d", r.URL.Path, w2.status),
 				Req:   r,