feat(base): stateless gitlab.com credential helper, split helpers into 12b (SCRUM-1952) - #99
Open
maxsv0 wants to merge 1 commit into
Open
feat(base): stateless gitlab.com credential helper, split helpers into 12b (SCRUM-1952)#99maxsv0 wants to merge 1 commit into
maxsv0 wants to merge 1 commit into
Conversation
…o 12b (SCRUM-1952) gitlab.com had NO git credential helper. `glab` has been installed unconditionally since 03b (SCRUM-1958), but nothing ever registered a credential source for the host, so every private GitLab clone died with: fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled Verified live on a customer agent: GITLAB_TOKEN present in ~/.agent-env, `git clone` still failing with exactly that error. Two things were broken, and fixing only one would not have helped: 1. No gitlab.com helper. Added, shaped like the Bitbucket one rather than the gh one: it answers git's credential protocol directly instead of shelling out to `glab auth git-credential`. That avoids a stored `glab auth login` — state that goes stale against ~/.agent-env, needs --insecure-storage to stay readable from systemd/cron, and cannot be registered before a token exists, which re-opens the provision-order race this is meant to close. Stateless means a token dropped in at any later time works on the very next git command: no login, no re-auth, no reboot. `username=oauth2` is verified against gitlab.com's smart-HTTP endpoint (200 with a valid token, 401 with a bad one). 2. The helpers lived in 12-workspace.sh, which is policy-excluded from refresh-manifest.txt as one-time user/workspace setup. So no helper fix could EVER reach an already-provisioned agent. Split the block into 12b-git-credential-helpers.sh — pure idempotent `git config` writes, nothing installed — and list that in the manifest, same carve-out shape as 15b. 12 itself stays excluded. Also hands ~/.gitconfig back to the agent user: `git config -f` rewrites via temp+rename, so the newly-reachable root-run refresh path would otherwise leave it root-owned and break `git config --global`. No credential is ever written to .gitconfig — every helper sources ~/.agent-env at call time, which is also what makes rotation a no-op. test-12b-git-credential-helpers.sh covers wiring, the manifest invariant (12b in / 12 out), no-token-at-rest, and executes the step for real against a sandbox HOME: resolution, rotation without re-auth, clean decline when no token is set, and idempotency across repeated runs. Suite: 22 passed before, 23 after; the same 6 pre-existing macOS `realpath -m` failures are unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Problem
gitlab.comhad no git credential helper at all.glabhas been installed unconditionally since03b(SCRUM-1958), but nothing ever registered a credential source for the host, so every private GitLab clone died with:Confirmed live on a customer agent:
GITLAB_TOKENcorrectly present in~/.agent-env,POST /api/projects/applystill failing with exactly that error and an empty workspace.Two independent defects — fixing either alone would not have helped.
1. No gitlab.com helper
Added, shaped like the Bitbucket helper rather than the
ghone: it answers git's credential protocol directly instead of shelling out toglab auth git-credential.Routing through
glabwould require a storedglab auth login, which:--insecure-storage, because glab prefers the OS keyring, which is unreadable from systemd units and cron.Stateless means a token dropped in at any later time works on the very next git command: no login, no re-auth, no reboot.
username=oauth2is verified against gitlab.com's smart-HTTP endpoint (200 with a valid token, 401 with a bad one).glabstays exactly what it is good for —glab mr create, which readsGITLAB_TOKENfrom the env job preambles already source.2. The fix could never have reached the fleet
The helpers lived in
12-workspace.sh, which is policy-excluded fromrefresh-manifest.txtas one-time user/workspace setup. So no credential-helper fix could ever reach an already-provisioned agent.Split the block into
12b-git-credential-helpers.sh— pure idempotentgit configwrites, nothing installed — and listed that in the manifest, same carve-out shape as15b.12itself stays excluded.Also
Hands
~/.gitconfigback to the agent user.git config -frewrites via temp+rename, so the newly-reachable root-run refresh path would otherwise leave it root-owned and breakgit config --globalfor the agent. Provisioning never hit this; the refresh path does.No credential is ever written to
.gitconfig— every helper sources~/.agent-envat call time, which is also what makes rotation a no-op.Testing
test-12b-git-credential-helpers.sh(17 assertions) covers wiring, the manifest invariant (12bin /12out / no double-write left in12), no-token-at-rest, and executes the step for real against a sandbox HOME, driven throughgit credential fill:gitlab.com→username=oauth2+ current tokenset -euo pipefailBitbucket + portal-registry helpers re-verified after extraction.
Suite: 22 passed before → 23 after. The same 6 failures are present on untouched
origin/main(macOS BSDrealpathlacks-m) and are unrelated.Companion
the-assistant
docs/gitlab-agent-credential-laneconverges the two manual scripts on the same helper and corrects the docs.🤖 Generated with Claude Code