Skip to content

fix(github): nil-check token source to avoid panic when no token configured#8298

Merged
olblak merged 1 commit intoupdatecli:mainfrom
loispostula:fix/8297-github-token-nil-panic
Apr 8, 2026
Merged

fix(github): nil-check token source to avoid panic when no token configured#8298
olblak merged 1 commit intoupdatecli:mainfrom
loispostula:fix/8297-github-token-nil-panic

Conversation

@loispostula
Copy link
Copy Markdown
Contributor

Fix #8297

GetTokenSourceFromConfig / GetTokenSourceFromEnv legitimately return a nil oauth2.TokenSource when nothing is configured. GetAccessToken called Token() on that nil source, panicking deep inside Clone instead of returning a usable error.

Test

To test this pull request, you can run the following commands:

cd pkg/plugins/scms/github/token
go test

A regression test TestGetAccessToken_NilTokenSource was added asserting GetAccessToken(nil) returns an error without panicking.

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

Tradeoff

The error is still surfaced inside Clone rather than at SCM init time. Surfacing it earlier would be a larger change touching the GitHub SCM init path; this PR is the minimal fix to stop the panic.

Potential improvement

Detect "no token configured" at GitHub SCM init time and fail fast with an actionable message before reaching Clone.

…igured

GetTokenSourceFromConfig/Env legitimately return a nil oauth2.TokenSource
when nothing is configured. GetAccessToken called Token() on that nil
source, panicking deep inside Clone instead of returning a usable error.

Fixes updatecli#8297

Signed-off-by: Loïs Postula <lois@postu.la>
@loispostula loispostula requested a review from olblak April 7, 2026 19:35
@olblak olblak added resource-githubRelease Resource of kind GitHub Release github_actions Pull requests that update Github_actions code scm-github SCM of type GiHhub pullrequest-github scm-githubsearch labels Apr 8, 2026
@olblak olblak merged commit 3c4bbcf into updatecli:main Apr 8, 2026
7 checks passed
@olblak olblak added the bug Something isn't working label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working github_actions Pull requests that update Github_actions code pullrequest-github resource-githubRelease Resource of kind GitHub Release scm-github SCM of type GiHhub scm-githubsearch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nil pointer panic in GetAccessToken when no GitHub token is configured

2 participants