bug(clone): full-URL clone of forge X writes the ambient forge Y's credential wiring into the new repo - born broken, and auth login cannot repair it #197
Labels
No labels
breaking
bug
documentation
enhancement
epic
good first issue
help wanted
refactoring
resolution/duplicate
resolution/invalid
resolution/wontfix
security
severity/critical
severity/high
severity/low
severity/medium
status/abandoned
status/blocked
status/needs-decision
status/needs-info
status/needs-verification
testing
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sixfold-space/madtea#197
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Repro
Machine state: ambient madtea credentials configured for forge Y (global git config:
claude @ gitea.example). Forge X (codeberg.org) hosts the repo being cloned; the machine also has a host-keyed systemd-creds backend.The fresh clone is unusable for every repo-scoped API command, and the documented remedy (
auth login) completes successfully while fixing nothing. The only escape is hand-editing the repo's git config, which no user should need.Root cause
internal/service/git/clone.goresolves credentials via ambientGetCredentials(clone.go:120) without ever comparing the resolved forge against the host the user explicitly named in the URL. Three consequences, worst first:WriteRepoCredentialsstampsmadtea.url = <forge Y>+madtea.user = <Y's user>+ the backend marker into a repo whose origin is forge X. A localmadtea.urlis the FIRST link in the ADR 0025 resolution chain (config.go:305, ahead of the origin remote), so this override poisons every subsequent command: they target Y with the owner/repo slug parsed from the X origin (heresixfold_space/madtea, which on Y is named differently) -> 404.RunFirstTimeSetupcorrectly derives the forge from origin (setup.go:227-230, ADR 0025 par. 2), authenticates to X, and stores the token host-keyed - but never notices or clears the localmadtea.urloverride pointing at Y. The login reports success and changes nothing observable; whoami before and after are byte-identical.CloneResult.ForgeHostis taken from the ambient forge whenever credentials resolve (clone.go:124-126) - the actual-URL-host branch only runs with no credentials configured at all. So the user is told the clone came "from gitea.example" when git actually fetched from codeberg.org (the clone URL passes through untouched, clone.go:115; the askpass is host-scoped to Y per #1826, so X received no credentials and the clone only worked because the repo is public).Removing the wrong-host override is also all it takes for the existing machinery to work: in a bare dir with only
origin -> codeberg.organd no localmadtea.url, the ADR 0025 origin-first chain + host-keyed backend resolvehexajon @ codeberg.orgperfectly (verified live while diagnosing this).Expected
madtea.url/madtea.userinto the new clone - either write wiring that matches the origin host or write no URL override at all and let the origin-first chain do its job.auth loginshould detect a localmadtea.urloverride naming a DIFFERENT host than origin, and repair it (or at least warn loudly) instead of silently succeeding into an unchanged broken state. Split into a follow-up if preferred.Related
Observed on v0.15.4-0.20260717031522-615d2732ccad; line numbers from main @
86e55df6.