The best way to control Claude Code, Codex and more from any computer or phone
fix(gitlab): report an expired glab OAuth login as an auth error (#27511)
Daniel Walsh committed
Oct 31, 2026 at 22:39 UTC
84ad7aef6a70a52f3ebf2829ab0f09b9a6d1c33c
2 files changed
+23
-3
packages/source-control-gitlab/src/server/GitLabCli.test.ts
+13
@@ -82,6 +82,19 @@ layer("GitLabCli.layer", (it) => {
82
args: ["mr", "view", "--output", "json", "--", "42"],
83
}),
84
);
85
+ const classifyFailure = mockedRun.mock.calls.at(-1)?.[0].classifyFailure;
86
+ assert.strictEqual(
87
+ classifyFailure?.(
88
+ "x gitlab.example.test has not been authenticated with glab. Run `glab auth login`",
89
+ ),
90
+ "authentication",
91
+ );
92
+ assert.strictEqual(
93
+ classifyFailure?.(
94
+ 'Failed to get merge request 42: oauth2: "invalid_grant" "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."',
95
+ ),
96
+ "authentication",
97
+ );
98
}),
99
);
100
packages/source-control-gitlab/src/server/GitLabCli.ts
+10
-3
@@ -411,11 +411,18 @@ function parseRepositoryPath(repository: string): {
411
return { namespacePath, projectPath };
412
}
413
414
-// glab prints a missing project or merge request as a bare 404.
414
+// glab prints a missing project or merge request as a bare 404, and an expired
415
+// OAuth login as an `invalid_grant` refresh failure without suggesting `glab auth login`.
416
const classifyGlabFailure = (stderr: string): VcsProcessExitFailureKind | null => {
417
const normalized = stderr.toLowerCase();
417
- if (normalized.includes("glab auth login")) return "authentication";
418
- if (normalized.includes("not found") || normalized.includes("404")) return "not-found";
418
+ if (normalized.includes("glab auth login") || normalized.includes("invalid_grant")) {
419
+ return "authentication";
420
+ }
421
+
422
+ if (normalized.includes("not found") || normalized.includes("404")) {
423
+ return "not-found";
424
+ }
425
+
426
return null;
427
};
428