Skip to content

fix(repo): prevent GitHub API calls when GitHub is not configured#726

Open
jimcavoli wants to merge 1 commit intokubero-dev:mainfrom
jimcavoli:fix-625-gitea-github-calls
Open

fix(repo): prevent GitHub API calls when GitHub is not configured#726
jimcavoli wants to merge 1 commit intokubero-dev:mainfrom
jimcavoli:fix-625-gitea-github-calls

Conversation

@jimcavoli
Copy link
Copy Markdown

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:

  • Even with GitHub disabled (PAT not set), Kubero was still making calls to GitHub APIs and failing
  • Kubero was also making HTTP calls to the GitHub APIs with Gitea repository paths

Root Causes

  1. Client-side: The default selected tab (repotab) was hardcoded to 'github' regardless of which providers were actually enabled
  2. Server-side: The GitHub API constructor didn't properly handle undefined baseUrl values (the check if (baseUrl === '') missed undefined values)
  3. Server-side: All GitHub API methods would try to make HTTP requests even when no token was configured

Changes

Client (client/src/components/pipelines/form.vue)

  • Made listRepositories() async and wait for provider list to load before setting default tab
  • Set default tab to first enabled provider instead of hardcoding 'github'
  • Added guard in loadRepository() to skip API calls if the selected provider is not enabled

Server (server/src/repo/git/github.ts)

  • Fixed baseUrl check to handle both empty string and falsy/undefined values
  • Added token property and isConfigured() method to check if the API is properly configured
  • Added configuration guards to all public API methods:
    • getRepository()
    • getRepositories()
    • listRepos()
    • getBranches()
    • getReferences()
    • getPullrequests()

Testing

To verify this fix:

  1. Set up Kubero with only Gitea configured (no GitHub PAT)
  2. Create a new pipeline with "Enable Pipeline to build from Source"
  3. Confirm that GitHub tab is grayed out and not selected by default
  4. Connect a Gitea repository
  5. Verify no GitHub API calls are made in the logs

Fixes #625

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When using Gitea repository, Kubero calls Github

1 participant