Repository navigation
fix(session): prefer API keys over GitHub tokens - #486
Merged
Merged
Conversation
KNiepok
force-pushed
the
fix/prefer-api-key-over-github-token
branch
from
September 8, 2026 10:52
84874fc to
e39c20e
Compare
GitHub personal access tokens are being retired as an authentication method, because a PAT belongs to no OAuth application and so cannot be attributed to Spacelift. With github ahead of apikey, a caller who sets API key variables while migrating only lands on them by accident: the PAT is attempted first, fails, and the loop falls through on error. Every invocation burns a failed exchange, and the migration depends on error handling rather than on the credential that was added. Swapping the order makes adding an API key take effect directly. Error reporting no longer depends on that order either. It used to return whichever error came last, which happened to be the API key one only because apikey was tried last; reordering made a half-configured API key report a missing GitHub token instead. All failures are joined, so the reason the caller needs is present regardless of order. This changes documented precedence for callers that set both, so it is a behaviour change, not a silent fix. SPACELIFT_API_PREFERRED_METHOD is unaffected: it bypasses the ordering entirely. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
KNiepok
force-pushed
the
fix/prefer-api-key-over-github-token
branch
from
September 8, 2026 10:54
e39c20e to
47f5a2a
Compare
KNiepok
marked this pull request as ready for review
September 8, 2026 11:00
mbialon
approved these changes
Sep 8, 2026
1 task
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.
Description
GitHub personal access tokens are being retired as an authentication method (a PAT belongs to no OAuth application, so Spacelift cannot verify it was issued for Spacelift). Backend side: spacelift-io/backend#17064.
Env auth order changes from
token → github → apikeytotoken → apikey → github.Today a caller who adds API key variables to migrate only lands on them by accident: the PAT is tried first, fails, and the loop falls through on error (
from_environment.go:75-77). Every invocation burns a failed exchange. After this, adding an API key just works.This changes documented precedence for anyone setting both, so it is a behaviour change rather than a silent fix.
SPACELIFT_API_PREFERRED_METHODis unaffected, it bypasses the ordering entirely.Type of Change