Debian Codegraph @

debian/patches/0001-Ensure-compatibility-with-Go-1.27-and-encoding-json-.patch

raw
1 From: Nurzhan Muratkhan <[email protected]>
2 Date: Mon, 23 Feb 2026 19:54:55 +0500
3 Subject: Ensure compatibility with Go 1.27 and encoding/json/v2
4
5 Fix test failures occurring with Go 1.27:
6 - In TestNewRequest_invalidJSON, use an unencodable function field instead
7 of map[interface{}]interface{} and avoid asserting UnsupportedTypeError.
8 - In TestHookDelivery_ParsePayload_invalidPayload and
9 TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories*,
10 relax unmarshal error string checks to account for Go 1.27's updated
11 struct field path format in unmarshal errors.
12
13 [Backport divergence note: adapted error assertion checks to keep
14 context.Background() rather than t.Context() which was introduced in
15 later Go releases.]
16
17 Origin: backport, https://github.com/google/go-github/commit/92a3830f9be93a0a314c4d6c2726ee820cc79c2e
18 Bug-Debian: https://bugs.debian.org/1146199
19 Closes: #1146199
20 Forwarded: not-needed
21 ---
22 github/github_test.go | 5 +----
23 github/repos_hooks_deliveries_test.go | 3 ++-
24 github/security_advisories_test.go | 8 ++++----
25 3 files changed, 7 insertions(+), 9 deletions(-)
26
27 diff --git a/github/github_test.go b/github/github_test.go
28 index 9a369a2..61b33fc 100644
29 --- a/github/github_test.go
30 +++ b/github/github_test.go
31 @@ -539,16 +539,13 @@ func TestNewRequest_invalidJSON(t *testing.T) {
32 c := NewClient(nil)
33
34 type T struct {
35 - A map[interface{}]interface{}
36 + F func()
37 }
38 _, err := c.NewRequest("GET", ".", &T{})
39
40 if err == nil {
41 t.Error("Expected error to be returned.")
42 }
43 - if err, ok := err.(*json.UnsupportedTypeError); !ok {
44 - t.Errorf("Expected a JSON error; got %#v.", err)
45 - }
46 }
47
48 func TestNewRequest_badURL(t *testing.T) {
49 diff --git a/github/repos_hooks_deliveries_test.go b/github/repos_hooks_deliveries_test.go
50 index 057d712..ba5a3f0 100644
51 --- a/github/repos_hooks_deliveries_test.go
52 +++ b/github/repos_hooks_deliveries_test.go
53 @@ -11,6 +11,7 @@ import (
54 "fmt"
55 "net/http"
56 "reflect"
57 + "strings"
58 "testing"
59
60 "github.com/google/go-cmp/cmp"
61 @@ -261,7 +262,7 @@ func TestHookDelivery_ParsePayload_invalidPayload(t *testing.T) {
62 }
63
64 _, err := d.ParseRequestPayload()
65 - if err == nil || err.Error() != "json: cannot unmarshal string into Go struct field CheckRun.check_run.id of type int64" {
66 + if err == nil || !strings.Contains(err.Error(), "json: cannot unmarshal") || !strings.Contains(err.Error(), "check_run.id") {
67 t.Errorf("unexpected error: %v", err)
68 }
69 }
70 diff --git a/github/security_advisories_test.go b/github/security_advisories_test.go
71 index b43ef7f..9d4c975 100644
72 --- a/github/security_advisories_test.go
73 +++ b/github/security_advisories_test.go
74 @@ -589,8 +589,8 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg_Unmars
75 ctx := context.Background()
76 advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisoriesForOrg(ctx, "o", nil)
77 if err == nil {
78 - t.Errorf("Expected unmarshal error")
79 - } else if !strings.Contains(err.Error(), "json: cannot unmarshal number into Go struct field SecurityAdvisory.ghsa_id of type string") {
80 + t.Error("Expected unmarshal error")
81 + } else if !strings.Contains(err.Error(), "json: cannot unmarshal") || !strings.Contains(err.Error(), "ghsa_id") {
82 t.Errorf("ListRepositorySecurityAdvisoriesForOrg returned unexpected error: %v", err)
83 }
84 if got, want := resp.Response.StatusCode, http.StatusOK; got != want {
85 @@ -720,8 +720,8 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories_UnmarshalErr
86 ctx := context.Background()
87 advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, "o", "r", nil)
88 if err == nil {
89 - t.Errorf("Expected unmarshal error")
90 - } else if !strings.Contains(err.Error(), "json: cannot unmarshal number into Go struct field SecurityAdvisory.ghsa_id of type string") {
91 + t.Error("Expected unmarshal error")
92 + } else if !strings.Contains(err.Error(), "json: cannot unmarshal") || !strings.Contains(err.Error(), "ghsa_id") {
93 t.Errorf("ListRepositorySecurityAdvisories returned unexpected error: %v", err)
94 }
95 if got, want := resp.Response.StatusCode, http.StatusOK; got != want {