Skip to content

feat(github): read the token from GH_TOKEN / GITHUB_TOKEN - #4

Merged
petrus-v merged 1 commit into
petrus-v:mainfrom
bosd:env-github-token
Sep 30, 2026
Merged

petrus-v merged 1 commit into
petrus-v:mainfrom
bosd:env-github-token

Conversation

@bosd

@bosd bosd commented Sep 27, 2026 •

Copy link
Copy Markdown

Problem

The token is only read from ~/.config/uvault/config.toml. Two consequences we hit immediately:

  1. CI has to write a secret to disk before it can run uvault status.
  2. A developer with gh auth login already done still runs unauthenticated, and the warning is easy to scroll past:
WARNING: No GitHub token configured in ~/.config/uvault/config.toml.
Using unauthenticated access. You may hit rate limits.

That second one bit us for real. Unauthenticated GitHub allows 60 requests/hour; running status over a project with ~60 VCS dependencies exhausted the quota partway through and set a 59-minute backoff:

Request GET /repos/OCA/contract failed with 403: rate limit exceeded
Setting next backoff to 3541.154662s

I also lost a little time to XDG_CONFIG_HOME not being honoured (read_user_config uses Path.home()), which is fine, but it does mean there's currently no way to supply a token without writing the file.

Change

Consult GH_TOKEN, then GITHUB_TOKEN, when the user config has no token. Those are the names the GitHub CLI and GitHub Actions already set, so both work with zero configuration.

Purely additive: a token in ~/.config/uvault/config.toml still wins, so no existing setup changes behaviour. The warning now names the env vars too.

The token is currently only read from ~/.config/uvault/config.toml, so
CI has to write a secret to disk before it can run `uvault status`, and a
developer with `gh auth login` already done still gets:

    WARNING: No GitHub token configured in ~/.config/uvault/config.toml.
    Using unauthenticated access. You may hit rate limits.

That warning is easy to miss, and unauthenticated GitHub allows 60
requests/hour: running `status` over a project with ~60 VCS dependencies
exhausted the quota partway through and set a 59-minute backoff.

`GH_TOKEN` and `GITHUB_TOKEN` are the names the GitHub CLI and GitHub
Actions already set, so consulting them makes both work with no config
file. The change is purely additive — a token in the user config still
takes precedence, so no existing setup changes behaviour.

Docs updated; three tests cover env, the Actions fallback, and config
precedence. 100% coverage preserved.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ebcdc11) to head (006d96f).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main        #4   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines         1066      1074    +8     
=========================================
+ Hits          1066      1074    +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@petrus-v petrus-v left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback and improvement ! this is awesome !

@petrus-v
petrus-v merged commit 527c2ce into petrus-v:main Sep 30, 2026
11 checks passed
@bosd
bosd deleted the env-github-token branch October 1, 2026 10:10
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.

3 participants