The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 09:45 UTC
fix(github): the Pull Requests page lists a repository when GitHub search fails with a 5xx (#30974)
Julius Marminge committed
Nov 16, 2026 at 17:58 UTC
e9a1e8699e0b8530a27372de4a22e57cf1ebbe70
2 files changed
+68
-6
packages/source-control-github/src/server/GitHubPullRequestApi.test.ts
+54
@@ -2166,6 +2166,60 @@ layer("GitHubPullRequestApi.layer", (it) => {
2166
}),
2167
);
2168
2169
+ it.effect("lists the repository when GitHub's search answers with a bad gateway", () =>
2170
+ Effect.gen(function* () {
2171
+ mockedExecute.mockImplementation((call) =>
2172
+ Effect.succeed(
2173
+ matches(call, "PullRequestSearch")
2174
+ ? output('{"message":"Server Error"}', false, false, {}, 502)
2175
+ : output(listedPullRequests(2, 1)),
2176
+ ),
2177
+ );
2178
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2179
+
2180
+ const batch = yield* cli.listPullRequests({
2181
+ cwd: "/w",
2182
+ repository: "acme/web",
2183
+ host: "github.com",
2184
+ state: "open",
2185
+ involvement: "all",
2186
+ viewer: "bilal",
2187
+ limit: 10,
2188
+ });
2189
+
2190
+ expect(batch.items.map((item) => item.number)).toEqual([1, 2]);
2191
+ }),
2192
+ );
2193
+
2194
+ it.effect("fails a text search GitHub answers with a bad gateway, not with unfiltered rows", () =>
2195
+ Effect.gen(function* () {
2196
+ mockedExecute.mockImplementation((call) =>
2197
+ Effect.succeed(
2198
+ matches(call, "PullRequestSearch")
2199
+ ? output('{"message":"Server Error"}', false, false, {}, 502)
2200
+ : output(listedPullRequests(2, 1)),
2201
+ ),
2202
+ );
2203
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2204
+
2205
+ const error = yield* Effect.flip(
2206
+ cli.listPullRequests({
2207
+ cwd: "/w",
2208
+ repository: "acme/web",
2209
+ host: "github.com",
2210
+ state: "open",
2211
+ involvement: "all",
2212
+ viewer: "bilal",
2213
+ limit: 10,
2214
+ query: "flaky",
2215
+ }),
2216
+ );
2217
+
2218
+ expect(error).toMatchObject({ _tag: "GitHubApiResponseError", status: 502 });
2219
+ assert.isFalse(mockedExecute.mock.calls.some(([call]) => matches(call, "PullRequestList")));
2220
+ }),
2221
+ );
2222
+
2223
it.effect("keeps state and involvement filters on the search-free fallback", () =>
2224
Effect.gen(function* () {
2225
mockedExecute.mockReturnValueOnce(Effect.succeed(emptySearch()));
packages/source-control-github/src/server/GitHubPullRequestApi.ts
+14
-6
@@ -331,6 +331,11 @@ const isGraphQlClientError = (error: unknown): error is GraphQLClientError.Graph
331
332
const { isNotFoundOnly } = GitHubGraphQlClient;
333
334
+const isGitHubApiResponseError = Schema.is(GitHubRequestPolicy.GitHubApiResponseError);
335
+
336
+const isGitHubServerError = (error: unknown): boolean =>
337
+ isGitHubApiResponseError(error) && error.status >= 500;
338
+
339
const isMissingPullRef = ({ path, type }: GraphQLClientError.GraphQLError): boolean =>
340
type === "NOT_FOUND" && path?.join(".") === "repository.pullRequest.baseRef.compare";
341
@@ -1955,13 +1960,16 @@ export const make = Effect.gen(function* () {
1960
});
1961
}),
1962
);
1958
- // Unindexed repositories silently return no search rows; fall back to the repository listing.
1959
- const hasQuery = (input.query?.trim().length ?? 0) > 0;
1963
+ // Unindexed repositories silently return no search rows, and search can fail while the
1964
+ // listing answers. The listing cannot apply a text query or an `updated:<=` cursor.
1965
+ const listingServes = input.cursor === undefined && (input.query?.trim().length ?? 0) === 0;
1966
const listed = read(true).pipe(
1961
- Effect.filterOrElse(
1962
- (batch) => batch.items.length > 0 || input.cursor !== undefined || hasQuery,
1963
- () => read(false),
1964
- ),
1967
+ Effect.matchEffect({
1968
+ onSuccess: (batch) =>
1969
+ batch.items.length > 0 || !listingServes ? Effect.succeed(batch) : read(false),
1970
+ onFailure: (error) =>
1971
+ listingServes && isGitHubServerError(error) ? read(false) : Effect.fail(error),
1972
+ }),
1973
Effect.filterOrElse(
1974
(batch) => !stacks || batch.items.length === 0,
1975
(batch) =>