Skip to content

fix(config): default the GitHub VcsBaseUrl to api.github.com - #583

Open
djeebus wants to merge 3 commits into
mainfrom
fix/app-token-base-url
Open

djeebus wants to merge 3 commits into
mainfrom
fix/app-token-base-url

Conversation

@djeebus

@djeebus djeebus commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Problem

When VcsBaseUrl is unset, pkg/config defaults it to https://<vcs-type>.com. For GitLab that's the instance root the client expects. For GitHub it's https://github.com, the website, which is never a valid API base. Every GitHub code path had to ignore the value unless VcsUploadUrl was also set.

#575 (released in v3.6.0) didn't do that: it sets the ghinstallation transport's BaseURL whenever VcsBaseUrl is non-empty. On github.com, every installation-token request now goes to the website and fails:

could not refresh installation id …'s token: received non 2xx response status "422 Unprocessable Entity" when fetching https://github.com/app/installations/…/access_tokens

As a result, every github.com install using GitHub App auth on v3.6.0 or v3.7.0 can't call the API at all. Fetching PR details, posting comments and downloading archives all fail.

Fix

Make the default correct instead of working around it:

  • pkg/config defaults VcsBaseUrl to https://api.github.com for github, and to https://gitlab.com for gitlab as before.
  • VcsBaseUrl is now always the API base, and every config is built by config.New(), so DownloadArchive and the App transport use it directly. Neither guesses Enterprise from VcsUploadUrl or falls back when the value is empty.
  • The flag's help text (and the regenerated docs/usage.md) now says what the value is: the Enterprise API base (https://<host>/api/v3) or the self-hosted GitLab root.

NewClient still requires both URLs before it uses WithEnterpriseURLs, which needs an upload URL anyway.

Tests

  • TestNew_VcsBaseUrlDefault checks the defaults for both VCS types and that an explicit value is kept. It fails on the old default (https://github.com).
  • TestCreateHttpClientAppBaseURL now covers the defaulted https://api.github.com, and drops its empty-value case.
  • The DownloadArchive tests pass the base URL config.New() would give them. TestClient_DownloadArchive_DefaultedVcsBaseUrl is removed, because it only existed to encode the old default and HappyPath now covers github.com.

🤖 Generated with Claude Code

config defaulted VcsBaseUrl to "https://<vcs-type>.com". That is the
instance root GitLab wants, but on GitHub it's the website, never a valid
API base, so every GitHub code path had to ignore it unless VcsUploadUrl
was also set. #575 didn't, and pointed the App's installation-token
requests at https://github.com/app/installations/<id>/access_tokens, which
answers 422: on v3.6.0 and v3.7.0 every github.com install using App auth
fails every API call.

Default GitHub to https://api.github.com, and GitLab to https://gitlab.com
as before. VcsBaseUrl is now always the API base, and every config comes
through that default, so DownloadArchive and the App transport use it
directly: no guessing Enterprise from VcsUploadUrl, and no fallback for an
empty value. The flag's help text says what the value is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Temporary Helm chart (version 0.0.0-pr583) available:

Install directly:

helm install kubechecks oci://ghcr.io/zapier/charts/kubechecks --version 0.0.0-pr583

Pull to inspect:

helm pull oci://ghcr.io/zapier/charts/kubechecks --version 0.0.0-pr583

Note: OCI charts don't use helm repo add - use the chart URL directly.

Follow-up fixes from the review of this branch:

- config: reject unknown vcs-type values at config load; an env-sourced
  KUBECHECKS_VCS_TYPE bypasses the flag-level "one of" help text
- github_client: fail loudly in DownloadArchive when VcsBaseUrl is empty
  instead of building a relative archive URL; the client contract now
  states that pkg/config is expected to have defaulted it
- gitlab_client: extract gitlabArchiveURL and append /api/v4 exactly
  once, so legacy configs that already carry the suffix stop 404ing
- docs: document the KUBECHECKS_VCS_BASE_URL defaults in usage.md
- tests: cover the new validation, the empty base url, and both
  GitLab URL forms
The default column is generated from the flags' pflag defaults, and
vcs-base-url has none (it is defaulted from vcs-type at runtime), so the
hand-written default value did not match the output of 'make rebuild-docs'.

This branch has not been deployed

No deployments
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.

1 participant