client: fix GetByID to return (nil, nil) for no matching entry

GetByID should return (nil, nil) if there is no entry with the given
id instead of returning JSON decoding error.

Updates golang/go#54981

(x/pkgsite has to update its dependency to pick up the fix after this cl)

Change-Id: Idc4bc30b8fe747bd539af97a72e04b7e71e30005
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/430115
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
diff --git a/client/client.go b/client/client.go
index 1821b4e..b82c06b 100644
--- a/client/client.go
+++ b/client/client.go
@@ -316,6 +316,9 @@
 	if err != nil {
 		return zero, err
 	}
+	if len(content) == 0 {
+		return zero, nil
+	}
 	var t T
 	if err := json.Unmarshal(content, &t); err != nil {
 		return zero, err
diff --git a/client/client_test.go b/client/client_test.go
index 4ae115b..14d7cdb 100644
--- a/client/client_test.go
+++ b/client/client_test.go
@@ -285,9 +285,13 @@
 	for _, test := range []struct {
 		name   string
 		source string
+		in     string
+		want   *osv.Entry
 	}{
-		{name: "http", source: srv.URL},
-		{name: "file", source: localURL},
+		{name: "http", in: vulnID, source: srv.URL, want: want},
+		{name: "file", in: vulnID, source: localURL, want: want},
+		{name: "http", in: "NO-SUCH-VULN", source: srv.URL, want: nil},
+		{name: "http", in: "NO-SUCH-VULN", source: localURL, want: nil},
 	} {
 		t.Run(test.name, func(t *testing.T) {
 			client, err := NewClient([]string{test.source}, Options{})