Skip to content

Commit 4da5e81

Browse files
fix(gitlab): any failed signed-in-host lookup retries glab's own host
A rate limit or other failure on the inferred self-hosted host returned an error where main resolves a public gitlab.com project. The lookup is read-only, so retry glab's own host after any failure from the inferred host, not only not-found. AI-assisted; verified with the tests and tools listed above.
1 parent 623e4c9 commit 4da5e81

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

‎packages/source-control-gitlab/src/server/GitLabCli.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ layer("GitLabCli.layer", (it) => {
310310
}),
311311
);
312312

313-
it.effect("falls back to glab's own host when the signed-in host lacks the project", () =>
313+
it.effect("falls back to glab's own host when the signed-in host lookup fails", () =>
314314
Effect.gen(function* () {
315315
mockGlab(["gitlab.selfhosted.test"]);
316316
const answer = mockedRun.getMockImplementation()!;
@@ -322,8 +322,8 @@ layer("GitLabCli.layer", (it) => {
322322
command: "glab",
323323
cwd: "/server",
324324
exitCode: 1,
325-
detail: "GET 404 project not found",
326-
failureKind: "not-found",
325+
detail: "GET 429 too many requests",
326+
failureKind: "rate-limited",
327327
}),
328328
)
329329
: answer(input),

‎packages/source-control-gitlab/src/server/GitLabCli.ts‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
TrimmedNonEmptyString,
1313
type SourceControlRepositoryVisibility,
1414
type VcsError,
15-
VcsProcessExitError,
1615
type VcsProcessExitFailureKind,
1716
} from "@t3tools/contracts";
1817

@@ -28,7 +27,6 @@ import type * as SourceControlProvider from "@t3tools/source-control-core/server
2827

2928
const DEFAULT_TIMEOUT_MS = 30_000;
3029
const AUTH_STATUS_TIMEOUT_MS = 5_000;
31-
const isVcsProcessExitError = Schema.is(VcsProcessExitError);
3230

3331
// glab reads its fallback host from these, so a set one means the user chose the host.
3432
const glabHostIsExplicit = Config.all(
@@ -603,13 +601,7 @@ export const make = Effect.gen(function* () {
603601
env === undefined
604602
? lookup()
605603
: // A public gitlab.com project still resolves through glab's own fallback host.
606-
lookup(env).pipe(
607-
Effect.catchIf(
608-
(error) =>
609-
isVcsProcessExitError(error.cause) && error.cause.failureKind === "not-found",
610-
() => lookup(),
611-
),
612-
),
604+
lookup(env).pipe(Effect.catch(() => lookup())),
613605
),
614606
Effect.map((result) => result.stdout.trim()),
615607
Effect.flatMap((raw) =>

0 commit comments

Comments
 (0)