diff --git a/ee/tabby-webserver/src/service/repository/third_party.rs b/ee/tabby-webserver/src/service/repository/third_party.rs index 94f9a8a2e0c6..3d6d3835197c 100644 --- a/ee/tabby-webserver/src/service/repository/third_party.rs +++ b/ee/tabby-webserver/src/service/repository/third_party.rs @@ -154,20 +154,16 @@ impl ThirdPartyRepositoryService for ThirdPartyRepositoryServiceImpl { .await { Ok(repos) => repos, - Err((e, true)) => { + Err(e) => { self.integration .update_integration_sync_status(provider.id.clone(), Some(e.to_string())) .await?; error!( - "Credentials for integration {} are expired or invalid", + "Failed to fetch repositories from integration: {}", provider.display_name ); return Err(e.into()); } - Err((e, false)) => { - error!("Failed to fetch repositories from github: {e}"); - return Err(e.into()); - } }; refresh_repositories_for_provider(self, &*self.integration, provider, repos).await?; diff --git a/ee/tabby-webserver/src/service/repository/third_party/fetch.rs b/ee/tabby-webserver/src/service/repository/third_party/fetch.rs index b62af66d57c8..364576c3669e 100644 --- a/ee/tabby-webserver/src/service/repository/third_party/fetch.rs +++ b/ee/tabby-webserver/src/service/repository/third_party/fetch.rs @@ -1,4 +1,3 @@ -use octocrab::GitHubError; use tabby_schema::integration::IntegrationKind; use self::{github::fetch_all_github_repos, gitlab::fetch_all_gitlab_repos}; @@ -16,26 +15,13 @@ pub async fn fetch_all_repos( kind: IntegrationKind, access_token: &str, api_base: &str, -) -> Result, (anyhow::Error, bool)> { +) -> Result, anyhow::Error> { match kind { IntegrationKind::Github | IntegrationKind::GithubSelfHosted => { - match fetch_all_github_repos(access_token, api_base).await { - Ok(repos) => Ok(repos), - Err(octocrab::Error::GitHub { - source: source @ GitHubError { .. }, - .. - }) if source.status_code.is_client_error() => Err((source.into(), true)), - Err(e) => Err((e.into(), false)), - } + Ok(fetch_all_github_repos(access_token, api_base).await?) } IntegrationKind::Gitlab | IntegrationKind::GitlabSelfHosted => { - match fetch_all_gitlab_repos(access_token, api_base).await { - Ok(repos) => Ok(repos), - Err(e) => { - let client_error = e.is_client_error(); - Err((e.into(), client_error)) - } - } + Ok(fetch_all_gitlab_repos(access_token, api_base).await?) } } } diff --git a/ee/tabby-webserver/src/service/repository/third_party/fetch/gitlab.rs b/ee/tabby-webserver/src/service/repository/third_party/fetch/gitlab.rs index eade4e70792b..e5f5df474847 100644 --- a/ee/tabby-webserver/src/service/repository/third_party/fetch/gitlab.rs +++ b/ee/tabby-webserver/src/service/repository/third_party/fetch/gitlab.rs @@ -1,5 +1,5 @@ use gitlab::{ - api::{projects::Projects, ApiError, AsyncQuery, Pagination}, + api::{projects::Projects, AsyncQuery, Pagination}, GitlabBuilder, }; use serde::Deserialize; @@ -23,25 +23,6 @@ pub enum GitlabError { Projects(#[from] gitlab::api::projects::ProjectsBuilderError), } -impl GitlabError { - pub fn is_client_error(&self) -> bool { - match self { - GitlabError::Rest(source) - | GitlabError::Gitlab(gitlab::GitlabError::Api { source }) => { - matches!( - source, - ApiError::Auth { .. } - | ApiError::Client { - source: gitlab::RestError::AuthError { .. } - } - | ApiError::Gitlab { .. } - ) - } - _ => false, - } - } -} - pub async fn fetch_all_gitlab_repos( access_token: &str, api_base: &str,