internal/worker: save proxy error rows

Upon a proxy error, a row was updated with the error but then completely
disregarded. This CL changes that.

Change-Id: I42f537a2a050ef0875a8335975ed0680f341b05f
Reviewed-on: https://go-review.googlesource.com/c/pkgsite-metrics/+/523055
Reviewed-by: Maceo Thompson <maceothompson@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
diff --git a/internal/worker/govulncheck_scan.go b/internal/worker/govulncheck_scan.go
index 7545e05..29fccd4 100644
--- a/internal/worker/govulncheck_scan.go
+++ b/internal/worker/govulncheck_scan.go
@@ -291,21 +291,23 @@
 		ModulePath:  sreq.Module,
 		Suffix:      sreq.Suffix,
 		WorkVersion: *s.workVersion,
+		ScanMode:    sreq.Mode,
+		ImportedBy:  sreq.ImportedBy,
 	}
+	row.VulnDBLastModified = s.workVersion.VulnDBLastModified
+
 	// Scan the version.
 	log.Debugf(ctx, "fetching proxy info: %s@%s", sreq.Path(), sreq.Version)
 	info, err := s.proxyClient.Info(ctx, sreq.Module, sreq.Version)
 	if err != nil {
 		log.Errorf(ctx, err, "proxy error")
 		row.AddError(fmt.Errorf("%v: %w", err, derrors.ProxyError))
-		return nil
+		// TODO: should we also make a copy for imports mode?
+		return writeResult(ctx, sreq.Serve, w, s.bqClient, govulncheck.TableName, row)
 	}
 	row.Version = info.Version
 	row.SortVersion = version.ForSorting(row.Version)
 	row.CommitTime = info.Time
-	row.ImportedBy = sreq.ImportedBy
-	row.VulnDBLastModified = s.workVersion.VulnDBLastModified
-	row.ScanMode = sreq.Mode
 
 	if sreq.Mode == ModeCompare {
 		return s.CompareModule(ctx, w, sreq, info, row)