Skip to content

Commit 2c69169

Browse files
only21milJorrinKievitclaude
committed
fix(server): leave a host glab cannot confirm uncached
When glab lists the remote's host but holds no account for it, its API call failed or its token was rejected, so glab could not tell either way. The GitLab refiner now returns "could not tell" for that host instead of a decline, and the verdict is not cached. Output that lists only other hosts still settles a decline. Co-authored-by: JorrinKievit <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3f6d0f8 commit 2c69169

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

‎apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,39 @@ it.effect.each([
779779
}),
780780
);
781781

782+
it.effect("does not keep a decline for a host glab could not confirm", () =>
783+
Effect.gen(function* () {
784+
// glab lists the host, but its API call failed, so the record holds no account.
785+
const unconfirmedGitLab = processOutput(
786+
`git.example.internal
787+
x git.example.internal: API call failed: GET https://git.example.internal/api/v4/user: dial tcp: i/o timeout
788+
✓ Git operations for git.example.internal configured to use https protocol.
789+
`,
790+
{ exitCode: ChildProcessSpawner.ExitCode(1) },
791+
);
792+
const outputs = [unconfirmedGitLab, signedInGitLab];
793+
const registry = yield* makeRegistry({
794+
remotes: [],
795+
process: {
796+
run: ({ command }) =>
797+
Effect.succeed(
798+
command === "glab" ? (outputs.shift() ?? noGitLabLogin) : processOutput(""),
799+
),
800+
},
801+
});
802+
const resolveKind = registry
803+
.resolveHandle({
804+
cwd: "/repo",
805+
context: unknownRemote("https://git.example.internal/team/a.git"),
806+
})
807+
.pipe(Effect.map((handle) => handle.provider.kind));
808+
809+
assert.strictEqual(yield* resolveKind, "unknown");
810+
assert.strictEqual(yield* resolveKind, "gitlab");
811+
assert.strictEqual(outputs.length, 0);
812+
}),
813+
);
814+
782815
it.effect("keeps Forgejo mounts on one host apart", () =>
783816
Effect.gen(function* () {
784817
const logins: Array<string> = [];

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,16 @@ function refineUnknownGitLabRemote(input: SourceControlUnknownRemoteRefinementIn
9292
if (hosts.length === 0) {
9393
return NO_GITLAB_LOGIN_PATTERN.test(output) ? null : undefined;
9494
}
95-
const authenticated = hosts.some((entry) => entry.account !== null && entry.host === host);
95+
const records = hosts.filter((entry) => entry.host === host);
9696

97-
if (!authenticated) {
97+
if (records.length === 0) {
9898
return null;
9999
}
100+
// A record for this host with no account (its API call failed or its token was rejected) means
101+
// glab could not confirm this host either way.
102+
if (!records.some((entry) => entry.account !== null)) {
103+
return undefined;
104+
}
100105

101106
return {
102107
kind: SourceControlProviderKind.make("gitlab"),

0 commit comments

Comments
 (0)