Skip to content

git: proactive auth for github.com only when the token is set - #4

Open
ditschi wants to merge 2 commits into
mainfrom
github-proactive-auth-token
Open

ditschi wants to merge 2 commits into
mainfrom
github-proactive-auth-token

Conversation

@ditschi

@ditschi ditschi commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Problem

On main, the CI jobs apt-rpi-zero (26.04) and apt-home-laptop fail in assert_second_apply_is_idempotent: the machine apply health check reports git-credential-env: GITHUB_TOKEN is not set.

The cause is http.https://github.com/.proactiveAuth = basic in private.gitconfig. It makes Git ask for a credential before the first request. With no token, Git then asks for a password, so even public github.com clones fail. In a fresh container, the antidote clones at the first zsh start fail this way: the helper's hint and Git's error go to stderr, and the plugins stay missing. Making the helper quiet would not help, because GitHub answers 401 to empty or wrong Basic credentials on public repos too.

Change

  • machine writes proactiveAuth = basic into the generated ~/.config/git/github-token.gitconfig only when the token variable is set at apply time. It looks in the environment first, then in ~/.env* through the checkout's environment loader.
  • private.gitconfig no longer sets the key itself.
  • With a token, nothing changes: the netrc protection stays. Without a token, Git is anonymous and runs the helper only after a 401, which still prints the hint.
  • OpenSpec change github-proactive-auth-token, archived: the git-config spec is updated. docs/git.md is updated as well.

Validation

  • pytest tests/unit/test_dotfiles.py tests/unit/test_gitconfig.py -q: 105 passed
  • test_host_yaml_install.py, -k "rpi_zero or home_laptop", Ubuntu 26.04, Docker, no token: 2 passed
  • Manual check with a temporary HOME and no token: a public clone and fetch succeed silently; a repository that answers 401 still shows the hint
  • pre-commit on the changed files, openspec validate --specs --strict: pass

🤖 Generated with Claude Code

Christian Ditscher added 2 commits November 26, 2026 20:33
With http.https://github.com/.proactiveAuth = basic and no token, Git asks
for a password before the first request, so even public clones fail. On a
fresh host the zsh plugin clones then print the credential helper's hint
and Git errors, and the machine apply health check fails (CI apt-rpi-zero,
apt-home-laptop).

machine now writes proactiveAuth into github-token.gitconfig only when the
token variable resolves at apply time (environment or ~/.env*). Without a
token Git stays anonymous and runs the helper only after a 401.
…-helper requirement and add anonymous access without a token
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.

1 participant