Decouple git from github errors (#1347)
* Decouple git from github errors
* Fix git error display (vibe-kanban 7352dadc)
After the last few commits git cli not logged in error does not get displayed to the user. Network tab shows this:
{
"success": false,
"data": null,
"error_data": {
"type": "git_cli_not_logged_in"
},
"message": null
}
This commit is contained in:
@@ -16,12 +16,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { attemptsApi } from '@/lib/api.ts';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import {
|
||||
GitBranch,
|
||||
GitHubServiceError,
|
||||
TaskAttempt,
|
||||
TaskWithAttemptStatus,
|
||||
} from 'shared/types';
|
||||
import { GitBranch, TaskAttempt, TaskWithAttemptStatus } from 'shared/types';
|
||||
import { projectsApi } from '@/lib/api.ts';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import NiceModal, { useModal } from '@ebay/nice-modal-react';
|
||||
@@ -166,49 +161,34 @@ const CreatePRDialogImpl = NiceModal.create<CreatePRDialogProps>(
|
||||
};
|
||||
|
||||
if (result.error) {
|
||||
switch (result.error) {
|
||||
case GitHubServiceError.GH_CLI_NOT_INSTALLED: {
|
||||
if (isMacEnvironment) {
|
||||
await showGhCliSetupDialog();
|
||||
} else {
|
||||
const ui = mapGhCliErrorToUi(
|
||||
'SETUP_HELPER_NOT_SUPPORTED',
|
||||
defaultGhCliErrorMessage,
|
||||
t
|
||||
);
|
||||
setGhCliHelp(ui.variant ? ui : null);
|
||||
setError(ui.variant ? null : ui.message);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case GitHubServiceError.TOKEN_INVALID: {
|
||||
if (isMacEnvironment) {
|
||||
await showGhCliSetupDialog();
|
||||
} else {
|
||||
const ui = mapGhCliErrorToUi(
|
||||
'SETUP_HELPER_NOT_SUPPORTED',
|
||||
defaultGhCliErrorMessage,
|
||||
t
|
||||
);
|
||||
setGhCliHelp(ui.variant ? ui : null);
|
||||
setError(ui.variant ? null : ui.message);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case GitHubServiceError.INSUFFICIENT_PERMISSIONS:
|
||||
setError(t('createPrDialog.errors.insufficientPermissions'));
|
||||
setGhCliHelp(null);
|
||||
return;
|
||||
case GitHubServiceError.REPO_NOT_FOUND_OR_NO_ACCESS:
|
||||
setError(t('createPrDialog.errors.repoNotFoundOrNoAccess'));
|
||||
setGhCliHelp(null);
|
||||
return;
|
||||
default:
|
||||
setError(
|
||||
result.message || t('createPrDialog.errors.failedToCreate')
|
||||
if (
|
||||
result.error.type === 'github_cli_not_installed' ||
|
||||
result.error.type === 'github_cli_not_logged_in'
|
||||
) {
|
||||
if (isMacEnvironment) {
|
||||
await showGhCliSetupDialog();
|
||||
} else {
|
||||
const ui = mapGhCliErrorToUi(
|
||||
'SETUP_HELPER_NOT_SUPPORTED',
|
||||
defaultGhCliErrorMessage,
|
||||
t
|
||||
);
|
||||
setGhCliHelp(null);
|
||||
return;
|
||||
setGhCliHelp(ui.variant ? ui : null);
|
||||
setError(ui.variant ? null : ui.message);
|
||||
}
|
||||
return;
|
||||
} else if (
|
||||
result.error.type === 'git_cli_not_installed' ||
|
||||
result.error.type === 'git_cli_not_logged_in'
|
||||
) {
|
||||
const gitCliErrorKey =
|
||||
result.error.type === 'git_cli_not_logged_in'
|
||||
? 'createPrDialog.errors.gitCliNotLoggedIn'
|
||||
: 'createPrDialog.errors.gitCliNotInstalled';
|
||||
|
||||
setError(result.message || t(gitCliErrorKey));
|
||||
setGhCliHelp(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -341,7 +341,9 @@
|
||||
"errors": {
|
||||
"insufficientPermissions": "Insufficient permissions. Please ensure the GitHub CLI has the necessary permissions.",
|
||||
"repoNotFoundOrNoAccess": "Repository not found or no access. Please check your repository access and ensure you are authenticated.",
|
||||
"failedToCreate": "Failed to create GitHub PR"
|
||||
"failedToCreate": "Failed to create GitHub PR",
|
||||
"gitCliNotLoggedIn": "Git is not authenticated. Run \"gh auth login\" (or configure Git credentials) and try again.",
|
||||
"gitCliNotInstalled": "Git CLI is not installed. Install Git to create a PR."
|
||||
},
|
||||
"loginRequired": {
|
||||
"title": "Sign in to create a pull request",
|
||||
|
||||
@@ -117,7 +117,9 @@
|
||||
"errors": {
|
||||
"insufficientPermissions": "Permisos insuficientes. Por favor asegúrate de que la CLI de GitHub tenga los permisos necesarios.",
|
||||
"repoNotFoundOrNoAccess": "Repositorio no encontrado o sin acceso. Por favor verifica el acceso al repositorio y asegúrate de estar autenticado.",
|
||||
"failedToCreate": "Error al crear PR de GitHub"
|
||||
"failedToCreate": "Error al crear PR de GitHub",
|
||||
"gitCliNotLoggedIn": "Git no está autenticado. Ejecuta \"gh auth login\" (o configura las credenciales de Git) e inténtalo de nuevo.",
|
||||
"gitCliNotInstalled": "Git CLI no está instalado. Instala Git para crear una PR."
|
||||
},
|
||||
"loginRequired": {
|
||||
"title": "Inicia sesión para crear un pull request",
|
||||
|
||||
@@ -117,7 +117,9 @@
|
||||
"errors": {
|
||||
"insufficientPermissions": "権限が不足しています。GitHub CLIに必要な権限があることを確認してください。",
|
||||
"repoNotFoundOrNoAccess": "リポジトリが見つからないか、アクセス権がありません。リポジトリへのアクセス権を確認し、認証されていることを確認してください。",
|
||||
"failedToCreate": "GitHub PRの作成に失敗しました"
|
||||
"failedToCreate": "GitHub PRの作成に失敗しました",
|
||||
"gitCliNotLoggedIn": "Gitが認証されていません。\"gh auth login\" を実行するかGitの認証情報を設定してから再試行してください。",
|
||||
"gitCliNotInstalled": "Git CLIがインストールされていません。PRを作成するにはGitをインストールしてください。"
|
||||
},
|
||||
"loginRequired": {
|
||||
"title": "プルリクエストを作成するにはサインインしてください",
|
||||
|
||||
@@ -117,7 +117,9 @@
|
||||
"errors": {
|
||||
"insufficientPermissions": "권한이 부족합니다. GitHub CLI에 필요한 권한이 있는지 확인하세요.",
|
||||
"repoNotFoundOrNoAccess": "저장소를 찾을 수 없거나 액세스 권한이 없습니다. 저장소 액세스를 확인하고 인증되었는지 확인하세요.",
|
||||
"failedToCreate": "GitHub PR 생성에 실패했습니다"
|
||||
"failedToCreate": "GitHub PR 생성에 실패했습니다",
|
||||
"gitCliNotLoggedIn": "Git이 인증되지 않았습니다. \"gh auth login\"을 실행하거나 Git 자격 증명을 설정한 후 다시 시도하세요.",
|
||||
"gitCliNotInstalled": "Git CLI가 설치되어 있지 않습니다. PR을 생성하려면 Git을 설치하세요."
|
||||
},
|
||||
"loginRequired": {
|
||||
"title": "Pull Request를 만들려면 로그인하세요",
|
||||
|
||||
@@ -32,7 +32,6 @@ import {
|
||||
UpdateTask,
|
||||
UpdateTag,
|
||||
UserSystemInfo,
|
||||
GitHubServiceError,
|
||||
UpdateRetryFollowUpDraftRequest,
|
||||
McpServerQuery,
|
||||
UpdateMcpServersBody,
|
||||
@@ -71,6 +70,7 @@ import {
|
||||
CommitCompareResult,
|
||||
OpenEditorResponse,
|
||||
OpenEditorRequest,
|
||||
CreatePrError,
|
||||
} from 'shared/types';
|
||||
|
||||
// Re-export types for convenience
|
||||
@@ -615,12 +615,12 @@ export const attemptsApi = {
|
||||
createPR: async (
|
||||
attemptId: string,
|
||||
data: CreateGitHubPrRequest
|
||||
): Promise<Result<string, GitHubServiceError>> => {
|
||||
): Promise<Result<string, CreatePrError>> => {
|
||||
const response = await makeRequest(`/api/task-attempts/${attemptId}/pr`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return handleApiResponseAsResult<string, GitHubServiceError>(response);
|
||||
return handleApiResponseAsResult<string, CreatePrError>(response);
|
||||
},
|
||||
|
||||
startDevServer: async (attemptId: string): Promise<void> => {
|
||||
|
||||
Reference in New Issue
Block a user