fix: support GH_TOKEN alongside GITHUB_TOKEN - #73
Conversation
Match the gh CLI convention: GH_TOKEN takes precedence over GITHUB_TOKEN when both are set, and empty values are treated as unset. Updates the auth helper, user-facing tip/error messages, README, and CHANGELOG, and adds unit tests for precedence, fallback, unset, and empty-string cases.
fenfenai
left a comment
There was a problem hiding this comment.
Review Summary
Reviewed 3 files, 83 lines changed across 4 review aspects (bug detection, error handling, test coverage, doc/guideline compliance). The core change is clean and well-tested — the findings below are a stale doc and a test-pollution regression caused by the new precedence.
Important Issues (confidence 75–89)
docs/cli-reference.md:26 — Stale CLI reference (confidence: 85)
This line still reads:
Requires
GITHUB_TOKEN(GraphQL API requires authentication).
It contradicts the updated fetch_star_list_repos behavior, the README updates in this PR, and the new error message in github.rs:752. AGENTS.md asks docs to stay in sync with feature changes; the cli-reference is the canonical reference for skillshub star-list and should not be left behind.
Suggestion: Replace with: Requires GH_TOKEN or GITHUB_TOKEN (GraphQL API requires authentication). GH_TOKEN is checked first, matching the gh CLI.
(docs/git-based-taps.md:79 is fine — it explicitly describes past usage.)
src/registry/github.rs:1903 / :1949 — Test isolation regression (confidence: 88)
See inline comment.
Minor Issues (confidence 75)
src/registry/github.rs — Missing symmetric empty-string test (confidence: 75)
See inline comment.
Positive Observations
- The new
github_token()helper is small, focused, and correctly implements the precedence + empty-as-unset contract. - All four new tests use
#[serial]and follow capture → cleanup → assert ordering, so a panic doesn't leak env state. - README.md and CHANGELOG.md are updated consistently and the keep-a-changelog
### Changedentry is well-formed. - Every user-facing error message that used to say "GITHUB_TOKEN" is now updated (
get_default_branch,fetch_gist,fetch_star_list_repos, the rate-limit-tip print, and the >max wait error). - The empty-string-as-unset behavior in
fetch_star_list_reposis a real UX win: previouslyGITHUB_TOKEN=""slipped through and produced a confusing downstream 401; now it fails fast at the helper boundary.
Considered but did not flag
NotUnicodeenv values are silently swallowed byif let Ok(token) = std::env::var(...). Pre-existing pattern — the oldwith_authdid the same.- The behavior change where
GITHUB_TOKEN=""no longer producesBearer(empty) but instead falls through to anonymous requests. Observable, but a strict improvement in this codebase. Option::context(...)ongithub_token()(L751): correct —anyhow::Contextprovides this onOption.
Address review on #73: - Update docs/cli-reference.md to mention both GH_TOKEN and GITHUB_TOKEN (was stale after the precedence change). - Clear GH_TOKEN in test_fetch_star_list_repos_with_mock and test_fetch_star_list_repos_list_not_found so a developer with GH_TOKEN set in their shell does not silently bind their real token to the wiremock server. - Add test_github_token_treats_empty_github_token_as_unset to lock in the symmetric empty-string contract.
fenfenai
left a comment
There was a problem hiding this comment.
Re-Review: All findings addressed ✓
Verified aa91a04 against the three open findings from the prior review:
| # | Finding | Status |
|---|---|---|
| 1 | docs/cli-reference.md:26 stale doc |
✓ Updated to mention both GH_TOKEN and GITHUB_TOKEN, with GH_TOKEN precedence noted. |
| 2 | Test isolation regression at :1903 and :1949 |
✓ Both test_fetch_star_list_repos_with_mock and test_fetch_star_list_repos_list_not_found now remove_var("GH_TOKEN") before the dummy GITHUB_TOKEN set, and clear it again on cleanup. The added clarifying comment is helpful. |
| 3 | Missing symmetric empty-string test | ✓ test_github_token_treats_empty_github_token_as_unset added at L945–953, #[serial], follows the capture-then-cleanup-then-assert pattern. |
No new issues introduced by the fix-up commit. LGTM.
Reconcile concurrent version bumps: main shipped 1.0.4 (GH_TOKEN support, #73) while this branch bumped to 1.1.0 for the using-skillshub default. Keep 1.1.0 (feature > patch under semver) and slot main's 1.0.4 entry between 1.1.0 and 1.0.3 in CHANGELOG.
Summary
github_token()helper that readsGH_TOKENfirst, then falls back toGITHUB_TOKEN(matching theghCLI convention; empty values are treated as unset).Closes #67.
Test plan
cargo buildcargo test(281/281 passing, including 4 newtest_github_token_*cases)cargo clippy --all-targets -- -D warningsclean