fix(github): raise credential_command priority above github_tokens.toml and gh CLI#8748
fix(github): raise credential_command priority above github_tokens.toml and gh CLI#8748
Conversation
…ml and gh CLI credential_command is an explicit user configuration, so it should take precedence over passive file-based sources like github_tokens.toml and gh CLI's hosts.yml. New priority order: 1. MISE_GITHUB_ENTERPRISE_TOKEN (non-github.com only) 2. MISE_GITHUB_TOKEN / GITHUB_API_TOKEN / GITHUB_TOKEN 3. credential_command 4. github_tokens.toml 5. gh CLI (hosts.yml) 6. git credential fill Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request reconfigures the GitHub token resolution mechanism within Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Greptile SummaryThis PR promotes Key changes:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[resolve_token called] --> B{MISE_GITHUB_ENTERPRISE_TOKEN set\nand non-github.com host?}
B -- Yes --> Z1[Return EnvVar token]
B -- No --> C{MISE_GITHUB_TOKEN /\nGITHUB_API_TOKEN /\nGITHUB_TOKEN set?}
C -- Yes --> Z2[Return EnvVar token]
C -- No --> D{credential_command\nconfigured?}
D -- Yes, returns token --> Z3[Return CredentialCommand token ✅ NEW PRIORITY]
D -- Yes, returns nothing --> E
D -- No --> E{github_tokens.toml\nhas entry for host?}
E -- Yes --> Z4[Return TokensFile token]
E -- No --> F{gh CLI hosts.yml\nhas entry for host?}
F -- Yes --> Z5[Return GhCli token]
F -- No --> G{use_git_credentials\nenabled?}
G -- Yes --> Z6[Return GitCredential token]
G -- No --> Z7[Return None]
style Z3 fill:#d4edda,stroke:#28a745
style D fill:#fff3cd,stroke:#ffc107
Reviews (3): Last reviewed commit: "[autofix.ci] apply automated fixes (atte..." | Re-trigger Greptile |
There was a problem hiding this comment.
Code Review
This pull request reorders the priority of GitHub token resolution, specifically elevating credential_command to be checked before file-based sources like github_tokens.toml and gh CLI tokens. The documentation and e2e tests have been updated to reflect this new priority. Feedback includes suggestions to improve the consistency of the github.com token priority table in the documentation and to make a code block in src/github.rs more concise.
| | Priority | Source | | ||
| | -------- | ---------------------------------- | | ||
| | 1 | `MISE_GITHUB_TOKEN` env var | | ||
| | 2 | `GITHUB_API_TOKEN` env var | | ||
| | 3 | `GITHUB_TOKEN` env var | | ||
| | 4 | `credential_command` (if set) | | ||
| | 5 | `github_tokens.toml` (per-host) | | ||
| | 6 | gh CLI token (from `hosts.yml`) | | ||
| | 7 | `git credential fill` (if enabled) | |
There was a problem hiding this comment.
For consistency with the GitHub Enterprise hosts table and the code comments in src/github.rs, consider grouping the environment variables for github.com into a single priority. This would make the documentation easier to follow and more consistent across different sections.
| | Priority | Source | | |
| | -------- | ---------------------------------- | | |
| | 1 | `MISE_GITHUB_TOKEN` env var | | |
| | 2 | `GITHUB_API_TOKEN` env var | | |
| | 3 | `GITHUB_TOKEN` env var | | |
| | 4 | `credential_command` (if set) | | |
| | 5 | `github_tokens.toml` (per-host) | | |
| | 6 | gh CLI token (from `hosts.yml`) | | |
| | 7 | `git credential fill` (if enabled) | | |
| | Priority | Source | | |
| | -------- | ------------------------------------------------------------------ | | |
| | 1 | `MISE_GITHUB_TOKEN` / `GITHUB_API_TOKEN` / `GITHUB_TOKEN` env vars | | |
| | 2 | `credential_command` (if set) | | |
| | 3 | `github_tokens.toml` (per-host) | | |
| | 4 | gh CLI token (from `hosts.yml`) | | |
| | 5 | `git credential fill` (if enabled) | |
| let credential_command = &settings.github.credential_command; | ||
| if !credential_command.is_empty() { | ||
| if let Some(token) = get_credential_command_token(credential_command, lookup_host) { | ||
| return Some((token, TokenSource::CredentialCommand)); | ||
| } | ||
| } |
There was a problem hiding this comment.
This block can be made more concise by removing the intermediate credential_command variable.
| let credential_command = &settings.github.credential_command; | |
| if !credential_command.is_empty() { | |
| if let Some(token) = get_credential_command_token(credential_command, lookup_host) { | |
| return Some((token, TokenSource::CredentialCommand)); | |
| } | |
| } | |
| if !settings.github.credential_command.is_empty() { | |
| if let Some(token) = | |
| get_credential_command_token(&settings.github.credential_command, lookup_host) | |
| { | |
| return Some((token, TokenSource::CredentialCommand)); | |
| } | |
| } |
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.3.14 x -- echo |
18.9 ± 0.6 | 17.4 | 21.3 | 1.00 |
mise x -- echo |
19.0 ± 0.5 | 17.9 | 25.0 | 1.01 ± 0.04 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.3.14 env |
18.8 ± 0.8 | 17.5 | 28.3 | 1.01 ± 0.05 |
mise env |
18.7 ± 0.5 | 17.1 | 20.6 | 1.00 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.3.14 hook-env |
19.0 ± 0.6 | 17.9 | 24.7 | 1.00 |
mise hook-env |
19.2 ± 0.6 | 17.8 | 27.6 | 1.01 ± 0.04 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.3.14 ls |
19.5 ± 0.6 | 18.3 | 22.8 | 1.00 |
mise ls |
19.7 ± 0.5 | 18.5 | 22.2 | 1.01 ± 0.04 |
xtasks/test/perf
| Command | mise-2026.3.14 | mise | Variance |
|---|---|---|---|
| install (cached) | 119ms | 119ms | +0% |
| ls (cached) | 70ms | 69ms | +1% |
| bin-paths (cached) | 70ms | 69ms | +1% |
| task-ls (cached) | 719ms | 713ms | +0% |
Summary
credential_commandfrom priority 5 (last resort, tied withgit credential fill) to priority 3 (after env vars, before file-based sources)credential_commandis an explicit user configuration, so it should take precedence over passive file-based sources likegithub_tokens.tomland gh CLI'shosts.ymlgit credential fillremains as the lowest-priority fallback (priority 6) and is no longer blocked whencredential_commandis set but returns no tokenNew priority order:
MISE_GITHUB_ENTERPRISE_TOKENenv var (non-github.com only)MISE_GITHUB_TOKEN/GITHUB_API_TOKEN/GITHUB_TOKENenv varscredential_command(if set)github_tokens.toml(per-host)hosts.yml)git credential fill(if enabled)Test plan
mise run test:e2e test_github_token)🤖 Generated with Claude Code
Note
Medium Risk
Changes GitHub authentication token resolution order, which can alter which credentials are sent to GitHub/GHE and affect rate limits or access in CI/dev environments. Scope is small and covered by updated e2e tests, but impacts a cross-cutting auth path.
Overview
Updates GitHub token resolution to check
credential_commandbeforegithub_tokens.tomland gh CLIhosts.yml, making the explicit user-configured command take precedence over file-based sources.Refreshes docs to reflect the new priority order for both github.com and GitHub Enterprise, and extends the
test_github_tokene2e coverage to assertcredential_commandwins over gh CLI andgithub_tokens.toml.Written by Cursor Bugbot for commit 74570de. This will update automatically on new commits. Configure here.