fix(repo): prevent GitHub API calls when GitHub is not configured#726
Open
jimcavoli wants to merge 1 commit intokubero-dev:mainfrom
Open
fix(repo): prevent GitHub API calls when GitHub is not configured#726jimcavoli wants to merge 1 commit intokubero-dev:mainfrom
jimcavoli wants to merge 1 commit intokubero-dev:mainfrom
Conversation
This fixes issue kubero-dev#625 where Kubero was making calls to GitHub APIs even when GitHub was disabled (no PAT set) and only Gitea was configured. Root causes and fixes: 1. Client-side: The default selected tab (repotab) was hardcoded to 'github' regardless of which providers were actually enabled. - Now waits for provider list to load before setting default tab - Sets default tab to first enabled provider - Added guard in loadRepository() to skip API calls if provider is not enabled 2. Server-side: The GitHub API constructor didn't properly handle undefined baseUrl values (the check 'if (baseUrl === "")' missed undefined values). - Fixed to check for both empty string and falsy values 3. Server-side: All GitHub API methods would try to make HTTP requests even when no token was configured. - Added isConfigured() check to all public API methods - Methods now return early with empty results if not configured Fixes kubero-dev#625
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes issue #625 where Kubero was making calls to GitHub APIs even when GitHub was disabled (no PAT set) and only Gitea was configured.
Problem
On Kubero v2.4.6, when setting up a pipeline with Gitea as the only configured provider:
Root Causes
repotab) was hardcoded to'github'regardless of which providers were actually enabledbaseUrlvalues (the checkif (baseUrl === '')missed undefined values)Changes
Client (
client/src/components/pipelines/form.vue)listRepositories()async and wait for provider list to load before setting default tabloadRepository()to skip API calls if the selected provider is not enabledServer (
server/src/repo/git/github.ts)baseUrlcheck to handle both empty string and falsy/undefined valuestokenproperty andisConfigured()method to check if the API is properly configuredgetRepository()getRepositories()listRepos()getBranches()getReferences()getPullrequests()Testing
To verify this fix:
Fixes #625