fix(gitlab): sanitize PAT auth failures across cli and web

This commit is contained in:
Tam Nhu Tran committed 2026-04-15 02:01:39 -04:00
1 parent 4e738ee021
commit 7f1c23607d
4 files changed
+171 -21

No files matched your search

+10 -15
View File
@@ -56,6 +56,7 @@ import {
} from './token-manager';
import { executeOAuthProcess } from './oauth-process';
import { importKiroToken } from './kiro-import';
import { parseGitLabPatAuthResponse } from './gitlab-pat-response';
import {
getProxyTarget,
buildProxyUrl,
@@ -723,22 +724,16 @@ async function handleGitLabPatLogin(
}),
});
const responseBody = (await response.text()).trim();
let payload: Record<string, unknown> = {};
if (responseBody) {
try {
payload = JSON.parse(responseBody) as Record<string, unknown>;
} catch {
payload = { error: responseBody };
}
}
const responseBody = await response.text();
const parsedResponse = parseGitLabPatAuthResponse(
response.ok,
response.status,
responseBody,
token
);
if (!response.ok || payload.status !== 'ok') {
const errorMessage =
(typeof payload.error === 'string' && payload.error) ||
responseBody ||
`GitLab PAT login failed with status ${response.status}`;
console.log(fail(errorMessage));
if (!parsedResponse.ok) {
console.log(fail(parsedResponse.errorMessage));
return null;
}