Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 4d6e894

Browse files
authored
fix(batches): don't request unnecessary info that's likely to cause GH errors (#64299)
Closes SRCH-802 After a long and unsuccessful hunt of eventual consistency errors, I noticed that we don't need the GraphQL fragments that are causing problems. I introduced a simplified request, which succeeds reliably. What customers should see now is one error (see second picture below), which is followed by a retry, and then success. Previously we've seen this error, sometimes less often, sometimes more, but customers saw it so often that it caused their batch changes to fail. <img width="1042" alt="Screenshot 2024-08-06 at 14 02 00" src="https://github.com/user-attachments/assets/c5a099da-d474-43db-ac12-ac7c4f22d4d3"> Customers may still see an initial error, which I've seen to reliably disappear on the first retry. It should not be a problem <img width="1039" alt="Screenshot 2024-08-06 at 14 02 48" src="https://github.com/user-attachments/assets/99f278d4-4020-48ea-b4ac-32cbdfce455d"> ## Test plan Manual testing ## Changelog - fix(batches): improve GitHub Apps integration reliability by simplifying the data requested from GitHub
1 parent 81fa144 commit 4d6e894

File tree

5 files changed

+157
-473
lines changed

5 files changed

+157
-473
lines changed

internal/batches/sources/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (s GitHubSource) createChangeset(ctx context.Context, c *Changeset, prInput
231231
if err != nil {
232232
return exists, errors.Wrap(err, "getting repo owner and name")
233233
}
234-
pr, err = s.client.GetOpenPullRequestByRefs(ctx, owner, name, c.BaseRef, c.HeadRef)
234+
pr, err = s.client.GetOpenPullRequestByRefsReduced(ctx, owner, name, c.BaseRef, c.HeadRef)
235235
if err != nil {
236236
return exists, errors.Wrap(err, "fetching existing PR")
237237
}

internal/batches/sources/testdata/golden/GithubSource_CreateChangeset_already_exists

Lines changed: 20 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -11,141 +11,33 @@
1111
"Number": 1,
1212
"ReviewDecision": "REVIEW_REQUIRED",
1313
"Author": {
14-
"AvatarURL": "https://avatars.githubusercontent.com/u/1185253?u=35f048c505007991433b46c9c0616ccbcfbd4bff\u0026v=4",
15-
"Login": "mrnugget",
16-
"URL": "https://github.com/mrnugget"
17-
},
18-
"BaseRepository": {
19-
"ID": "MDEwOlJlcG9zaXRvcnkyMjExNDc1MTM=",
20-
"Name": "automation-testing",
21-
"Owner": {
22-
"Login": "sourcegraph"
23-
}
24-
},
25-
"HeadRepository": {
26-
"ID": "MDEwOlJlcG9zaXRvcnkyMjExNDc1MTM=",
27-
"Name": "automation-testing",
28-
"Owner": {
29-
"Login": "sourcegraph"
30-
}
31-
},
32-
"Participants": [
33-
{
34-
"AvatarURL": "https://avatars.githubusercontent.com/u/1185253?u=35f048c505007991433b46c9c0616ccbcfbd4bff\u0026v=4",
14+
"AvatarURL": "https://avatars3.githubusercontent.com/u/1185253?v=4",
3515
"Login": "mrnugget",
3616
"URL": "https://github.com/mrnugget"
37-
},
38-
{
39-
"AvatarURL": "https://avatars.githubusercontent.com/u/19534377?v=4",
40-
"Login": "eseliger",
41-
"URL": "https://github.com/eseliger"
42-
}
43-
],
44-
"Labels": {
45-
"Nodes": []
4617
},
47-
"TimelineItems": [
48-
{
49-
"Type": "PullRequestCommit",
50-
"Item": {
51-
"Commit": {
52-
"OID": "9d04a0d8733dafbb5d75e594a9ec525c49dfc975",
53-
"Message": "Add another file",
54-
"MessageHeadline": "Add another file",
55-
"URL": "https://github.com/sourcegraph/automation-testing/commit/9d04a0d8733dafbb5d75e594a9ec525c49dfc975",
56-
"Committer": {
57-
"AvatarURL": "https://avatars.githubusercontent.com/u/1185253?v=4",
58-
"Email": "[email protected]",
59-
"Name": "Thorsten Ball",
60-
"User": {
61-
"AvatarURL": "https://avatars.githubusercontent.com/u/1185253?u=35f048c505007991433b46c9c0616ccbcfbd4bff\u0026v=4",
62-
"Login": "mrnugget",
63-
"URL": "https://github.com/mrnugget"
64-
}
65-
},
66-
"CommittedDate": "2019-11-12T06:38:55Z",
67-
"PushedDate": "2019-11-12T06:39:00Z"
68-
}
69-
}
70-
},
71-
{
72-
"Type": "PullRequestCommit",
73-
"Item": {
74-
"Commit": {
75-
"OID": "37406e7dfa4466b80d1da183d6477aac16b1e58c",
76-
"Message": "Test commit to always have a open PR",
77-
"MessageHeadline": "Test commit to always have a open PR",
78-
"URL": "https://github.com/sourcegraph/automation-testing/commit/37406e7dfa4466b80d1da183d6477aac16b1e58c",
79-
"Committer": {
80-
"AvatarURL": "https://avatars.githubusercontent.com/u/1185253?v=4",
81-
"Email": "[email protected]",
82-
"Name": "Thorsten Ball",
83-
"User": {
84-
"AvatarURL": "https://avatars.githubusercontent.com/u/1185253?u=35f048c505007991433b46c9c0616ccbcfbd4bff\u0026v=4",
85-
"Login": "mrnugget",
86-
"URL": "https://github.com/mrnugget"
87-
}
88-
},
89-
"CommittedDate": "2019-11-12T06:39:23Z",
90-
"PushedDate": "2019-11-12T06:39:33Z"
91-
}
92-
}
93-
},
94-
{
95-
"Type": "ClosedEvent",
96-
"Item": {
97-
"Actor": {
98-
"AvatarURL": "https://avatars.githubusercontent.com/u/19534377?v=4",
99-
"Login": "eseliger",
100-
"URL": "https://github.com/eseliger"
101-
},
102-
"CreatedAt": "2019-12-04T23:28:16Z",
103-
"URL": "https://github.com/sourcegraph/automation-testing/pull/1#event-2855920542"
104-
}
105-
},
106-
{
107-
"Type": "ReopenedEvent",
108-
"Item": {
109-
"Actor": {
110-
"AvatarURL": "https://avatars.githubusercontent.com/u/1185253?u=35f048c505007991433b46c9c0616ccbcfbd4bff\u0026v=4",
111-
"Login": "mrnugget",
112-
"URL": "https://github.com/mrnugget"
113-
},
114-
"CreatedAt": "2019-12-05T07:09:21Z"
18+
"BaseRepository": {
19+
"ID": "MDEwOlJlcG9zaXRvcnkyMjExNDc1MTM=",
20+
"Name": "automation-testing",
21+
"Owner": {
22+
"Login": "sourcegraph"
11523
}
116-
},
117-
{
118-
"Type": "RenamedTitleEvent",
119-
"Item": {
120-
"Actor": {
121-
"AvatarURL": "https://avatars.githubusercontent.com/u/1185253?u=35f048c505007991433b46c9c0616ccbcfbd4bff\u0026v=4",
122-
"Login": "mrnugget",
123-
"URL": "https://github.com/mrnugget"
124-
},
125-
"PreviousTitle": "This is a test PR that is always open",
126-
"CurrentTitle": "This is a test PR that is always open (keep it open!)",
127-
"CreatedAt": "2019-12-05T07:09:31Z"
24+
},
25+
"HeadRepository": {
26+
"ID": "MDEwOlJlcG9zaXRvcnkyMjExNDc1MTM=",
27+
"Name": "automation-testing",
28+
"Owner": {
29+
"Login": "sourcegraph"
12830
}
129-
}
130-
],
31+
},
13132
"Commits": {
132-
"Nodes": [
133-
{
134-
"Commit": {
135-
"OID": "37406e7dfa4466b80d1da183d6477aac16b1e58c",
136-
"CheckSuites": {
137-
"Nodes": []
138-
},
139-
"Status": {
140-
"State": "",
141-
"Contexts": null
142-
},
143-
"CommittedDate": "2019-11-12T06:39:23Z"
144-
}
145-
}
146-
]
33+
"Nodes": []
34+
},
35+
"Labels": {
36+
"Nodes": []
14737
},
38+
"Participants": [],
39+
"TimelineItems": [],
14840
"IsDraft": false,
14941
"CreatedAt": "2019-11-12T06:40:21Z",
15042
"UpdatedAt": "2023-02-03T20:42:20Z"
151-
}
43+
}

0 commit comments

Comments
 (0)