Repository navigation
Description
Problem
devops release pr (also reached through release prepare --create-pr) failed to push the release branch with this output, while git push from the same shell worked:
Warning: Could not push branch to remote: fatal: could not read Username for 'https://github.com': No such device or address
Checked offline at release/v0.2.25 (d37120b; every cited line is the same at 132ecc5), with GitPython 3.1.62 as pinned in pyproject.toml, on 2026-10-03. No push was run and no credential was read.
Cause: the push runs in run_subprocess's sanitized environment, which drops everything git's credential helpers need.
- The push is
run_subprocess(["git", "push", "-u", "origin", <branch>])(src/devops_cli/commands/release.py:822-824).release tag --pushpushes the same way (:1577).run_subprocessbuilds the child environment from an allowlist (src/devops_cli/core/process.py:27-84), removes names that match the deny patterns (:86-94), and puts tokens back only for aghargv (_inject_gh_credentials,:206-215, called at:247-248). - The devcontainer sets
GIT_CONFIG_COUNT,GIT_CONFIG_KEY_<n>andGIT_CONFIG_VALUE_<n>(.devcontainer/devcontainer.json:47-55,src/devops_cli/templates/devcontainer.json.j2:47-55). They givehttps://githubproxy.fjygbaifeng.eu.organ empty helper, which drops inherited helpers, and then!gh auth git-credential.GIT_CONFIG_COUNTandGIT_CONFIG_VALUE_<n>are not on the allowlist, andGIT_CONFIG_KEY_<n>matches*KEY*, so the child git never sees that helper. - That leaves the system and global helper. In the devcontainer it is VS Code's remote-containers helper, which reads
REMOTE_CONTAINERS_IPCto reach the editor. That variable is not on the allowlist either, so the helper returns nothing. - Restoring the helper would not be enough.
gh auth git-credentialreads gh's token from the keyring over the session bus, which is why_move_plaintext_gh_tokenspassesDBUS_SESSION_BUS_ADDRESS(withGH_CONFIG_DIRandXDG_CONFIG_HOME) to gh (src/devops_cli/commands/devcontainer.py:1451-1452). None of them is on the allowlist, andGH_TOKENandGITHUB_TOKENmatch*TOKEN*. SSH remotes fail too:SSH_AUTH_SOCKmatches*AUTH*, andGIT_ASKPASSandSSH_ASKPASSare not on the allowlist. - When no helper answers, git prompts on
/dev/tty. Without a controlling terminal (an agent, CI, a scheduled job), opening it fails with ENXIO, the "No such device or address" above. In a terminal, git stops in the middle of the command to ask for a username and password, and GitHub does not accept a password over HTTPS. - A call site cannot fix this with
extra_allowed_env. Deny patterns are applied first (core/process.py:145), soGIT_CONFIG_KEY_<n>,SSH_AUTH_SOCKandGH_TOKENcannot be allowed by name. - Observed in the devcontainer by listing
credential.*helperwithgit config --show-scope --get-regexp, once in the shell and once underbuild_subprocess_env():- The shell has the VS Code helper at system and global scope, then, at command scope, the reset and
!gh auth git-credentialfor github.com and gist.github.com. - The sanitized child has only the VS Code helper at system and global scope.
GIT_CONFIG_COUNT,GIT_CONFIG_KEY_0,GIT_CONFIG_VALUE_1,REMOTE_CONTAINERS_IPC,DBUS_SESSION_BUS_ADDRESSandXDG_RUNTIME_DIRare all set in the shell, and none of them reaches the child.
- The shell has the VS Code helper at system and global scope, then, at command scope, the reset and
- The rest of the code reaches remotes another way.
clone_repo,fetch_allandpull_tracking(src/devops_cli/git/operations.py:195-221) go through GitPython, which starts git from a copy of the full process environment, and feat(repos): Add a gitea remote to every clone under repos/ #1090 plans its Gitea push through GitPython'sRemote.push. The release pushes are the only exception. - feat(release): production service image for scheduled jobs and webhook handlers #753 already records the gap for the service image (
run_subprocesswithholds the token from git, so this push has no credential) and works around it there with a system-scope helper plus refactor(github): one github session per identity owning token, quota and transport #767's token pin. Neither reaches the devcontainer, whose helper lives in theGIT_CONFIG_*variables.
A failed push is only a warning. _commit_and_push_release_branch (release.py:825-829) prints the warning above, and release_pr goes on to run gh pr create --head release/vX.Y.Z (:1178-1207, --head at :1047). Item PRs merge into the release branch, so it already exists on the remote. The PR therefore opens against the remote tip, without the bump commit that was just made locally. release tag --push already exits 1 when its push fails (:1578-1582). #982 makes the whole release path fail closed (its step 4 and its pre-receive criterion). In this item the push raises an exception, which has the same effect at today's call site.
A working credential would not make today's branch push succeed. The release ruleset (23059172, read with gh api on 2026-10-03) targets refs/heads/release*/**/* with a pull_request rule and lists no bypass actor, so GitHub refuses a direct push of a new commit to release/vX.Y.Z. After this item, today's release pr stops with GitHub's refusal instead of opening a PR. #982 moves the push to chore/cut-vX.Y.Z, which no ruleset covers; that push and release tag --push are the ones this item makes work.
Acceptance criteria
-
src/devops_cli/git/operations.pygains two functions built on GitPython'sRemote.push:push_branch(repo_dir, branch, *, remote="origin", set_upstream=True);push_tags(repo_dir, *, remote="origin").
Both run git with the process environment plus
GIT_TERMINAL_PROMPT=0(Git.custom_environment), and passkill_after_timeout=DEFAULT_SUBPROCESS_TIMEOUT_SECONDS, the boundrun_subprocessapplies today. -
A failed push raises
GitOperationErrornaming the remote, the ref and git's message, passed throughmask_secrets. It covers all three ways GitPython reports a failure:Remote.pushraisesGitCommandErroritself when git reports no ref at all, which is this bug's case (no credential, unreachable remote);PushInfoList.raise_if_error()raises when git exited non-zero after reporting refs;- a
PushInfocarriesERROR, which GitPython sets for every!line: rejected, remote rejected, remote failure and no match.
-
_commit_and_push_release_branchand_push_git_tagcall these functions.rg -n '"push",' src/devops_cli/commandsfinds nothing. -
Environment test, with real git on
tmp_pathand no network:- Setup: a working repository with a bare
origin. The working repository'spre-pushhook writes what it sees to a file. - Environment: the test sets its own
GIT_CONFIG_COUNT=1,GIT_CONFIG_KEY_0=credential.https://example.com.helperandGIT_CONFIG_VALUE_0=!fake-helper, and dummy values forDBUS_SESSION_BUS_ADDRESS,REMOTE_CONTAINERS_IPC,SSH_AUTH_SOCKandGH_TOKEN.GIT_CONFIG_GLOBALandGIT_CONFIG_SYSTEMpoint at empty files. - Pass:
push_branchsucceeds, and the hook saw!fake-helperfromgit config --get-all credential.https://example.com.helper, each of those variables, andGIT_TERMINAL_PROMPT=0. - Fail on today's code: a
run_subprocess(["git", "push", ...])hook sees none of them.
- Setup: a working repository with a bare
-
Rejection test: the bare remote's
pre-receivehook exits 1.push_branchraisesGitOperationErrornaming the branch, and the remote ref does not move. With tags,push_tagsraises the same way. -
No-ref test: a remote whose path does not exist makes
push_branchraiseGitOperationError, notGitCommandError. -
Call sites:
- With
push_branchraising,devops release prexits non-zero with the error, andrun_ghis never called. This is the call-site half of fix(release): one fail-closed release path: cut branch from the remote release tip,uv.lockbump, draft flag, required label and milestone #982's pre-receive criterion. release tag --pushstill exits 1 on a failed push, now from the exception.tests/test_release.py:489,:536,:594and:716patch the new functions instead of matching agit pushargv. They must: the tag test's origin ishttps://github.com/example/tagged.git(:500), and patchingrun_subprocess(:523) no longer stops an unpatched GitPython push from reaching it.
- With
-
src/devops_cli/core/process.pydoes not change. Every other subprocess keeps the sanitized environment, andtests/test_subprocess_env_boundary.pypasses unchanged. -
The tests stay offline: local bare remotes, no socket, no real helper, and a dummy
GH_TOKENonly. Together they add under 1 s.uv run devops cipasses. -
Pending a person: in the devcontainer, from a shell with no controlling terminal (
setsid -w uv run python -c "from pathlib import Path; from devops_cli.git.operations import push_branch; push_branch(Path('.'), 'try/push-check')" < /dev/nullon a local branchtry/push-check), the push succeeds without a prompt andgit ls-remote origin try/push-checkshows the local commit; thengit push origin --delete try/push-check. Once fix(release): one fail-closed release path: cut branch from the remote release tip,uv.lockbump, draft flag, required label and milestone #982 has landed, its first cut run from an agent's shell pusheschore/cut-vX.Y.Zthe same way.
Key questions
- Why not widen the allowlist for git? Proposed: no.
- What a helper needs has no fixed list: VS Code's IPC socket, gh's keyring bus, an SSH agent, Git Credential Manager's own settings, askpass programs.
- Three of the names match deny patterns.
- A list maintained by hand drifts away from what each person's helper needs.
- A push devops runs for a person should get the same environment as that person's own
git push. GitPython already does this forclone_repo,fetch_allandpull_tracking, andtelemetry profiledoes it for its own child (src/devops_cli/commands/telemetry.py:334-346).
- Does this weaken the isolation
run_subprocessprovides? Proposed: no.- The isolation keeps ambient secrets away from scanners, linters and tools that run on trees devops-cli does not trust.
- The push runs git, plus the helpers and hooks the person configured (this repository installs pre-commit's
pre-pushhook type), in the project being released (--root). These are the same programs the person's owngit pushruns. src/devops_cli/core/process.pydoes not change.ai/review/samples.py:137-145fetches public sample repositories and keeps the sanitized environment.
- GitPython, or
run_subprocess(..., isolate_env=False)? Proposed: GitPython, ingit/operations.pynext to the other remote operations.- Results come from
PushInfoflags instead of parsed git output, as feat(repos): Add a gitea remote to every clone under repos/ #1090 specifies for its Gitea push. - One function can serve this item, fix(release): one fail-closed release path: cut branch from the remote release tip,
uv.lockbump, draft flag, required label and milestone #982's cut push (aspush_branch(..., force_with_lease=True), which GitPython passes as--force-with-lease; fix(release): one fail-closed release path: cut branch from the remote release tip,uv.lockbump, draft flag, required label and milestone #982 today names only the argv) and feat(repos): Add a gitea remote to every clone under repos/ #1090.
- Results come from
- Why
GIT_TERMINAL_PROMPT=0? Proposed: GitHub accepts no password over HTTPS, so the only possible answer to the prompt is a token pasted by hand. Without a terminal git already fails (ENXIO); with one, an agent or job that holds a pseudo-terminal would sit at the prompt until the timeout. With the prompt off, both fail at once with git's own reason ("terminal prompts disabled"), and the person fixes the helper (gh auth status,gh auth setup-git).ai/review/samples.py:141already sets it for the sample fetch. - What happens to refactor(github): one github session per identity owning token, quota and transport #767's git pin? Proposed: refactor(github): one github session per identity owning token, quota and transport #767's "git gets the pin" criterion targets a
git pushargv run throughrun_subprocess. After this item it applies topush_branchandpush_tagsthroughGit.custom_environment(GH_TOKEN=...). Because the environment is inherited, aGH_TOKENfrom the environment (the service's Secret, feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741) already reaches git and feat(release): production service image for scheduled jobs and webhook handlers #753's system-scopegh auth git-credentialhelper without the pin. Whichever of the two lands second moves the criterion. - Does
release prnow stop after a failed push? Proposed: yes. The exception ends the command beforegh pr create. fix(release): one fail-closed release path: cut branch from the remote release tip,uv.lockbump, draft flag, required label and milestone #982 still owns the rest of the fail-closed path: commit failures, the label and milestone fallbacks, and the cut branchchore/cut-vX.Y.Z. Whichever item lands second rebases onto the other's call. - Does any other remote git call in
src/go throughrun_subprocess? Proposed: no.rg -n '"git", "(push|fetch|pull|ls-remote|clone)"' srcfinds only the two pushes;samples.pybuilds its argv fromBIN_GITand is covered above. The devcontainer'sgit daemon(commands/devcontainer.py:1221-1262), a stub meant to give Argo CD a simple local Git source, only servesk8s/andrepos/read-only on port 9418; it pushes nothing and needs no credential.
Strategic alignment
- No milestone. P1: every push the release path makes from the standard devcontainer fails without a terminal and prompts with one, and the cut push fix(release): one fail-closed release path: cut branch from the remote release tip,
uv.lockbump, draft flag, required label and milestone #982 introduces for v0.2.26 inherits the same fault unless it callspush_branch. Today the only workaround is agit pushby hand. - Value / Effort: High / Small. Two functions in
git/operations.py, two call sites, four test updates and three small tests ontmp_pathrepositories. One PR. - Related: fix(release): one fail-closed release path: cut branch from the remote release tip,
uv.lockbump, draft flag, required label and milestone #982 (fail-closed release path; its cut push is proposed to callpush_branch), refactor(github): one github session per identity owning token, quota and transport #767 (GitHub token pin for git), feat(release): production service image for scheduled jobs and webhook handlers #753 (service image; records the same gap), feat(repos): Add a gitea remote to every clone under repos/ #1090 (Gitea push through GitPython), feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743 (automatic cut, which pushes through fix(release): one fail-closed release path: cut branch from the remote release tip,uv.lockbump, draft flag, required label and milestone #982). - Library-first: GitPython (already a dependency) and git's own credential helpers. There is no hand-maintained list of credential variables.
Update 2026-10-08: delivered scope
Delivered on fix/1124-release-push-person-environment. Where the delivered scope differs from the body above:
- The fail-closed half was mostly done already. fix(release): one fail-closed release path: cut branch from the remote release tip,
uv.lockbump, draft flag, required label and milestone #982 (v0.2.26) already exits 1 on a failed push beforegh pr create. This item keeps that behaviour and tightens it:test_release_cut_rejected_push_stops_before_ghrunsrelease prepare --create-pragainst a bare remote'spre-receivehook, andrelease pragainst the clone'spre-pushhook. Both exit 1 before gh is called, and the error carries git's reason (such as[remote rejected]), masked.- Git's text is printed as written. Before, Rich read it as markup:
[remote rejected]vanished, and a[/bold]in a remote message raisedMarkupError.
- No GitPython push functions.
Git.custom_environment(NAME=None)only drops GitPython's own override and never removes an inherited variable, so it cannot keep refactor(github): one github session per identity owning token, quota and transport #767's token rule. Instead, the release command's remote git calls go through one helper,_run_remote_git_or_exit. It runs git with the person's environment plusGIT_TERMINAL_PROMPT=0(CONST_GIT_NO_TERMINAL_PROMPT_ENV), and prints git's masked reason and exits 1 when git fails._pin_github_tokenapplies refactor(github): one github session per identity owning token, quota and transport #767 unchanged.core/process.pyandgit/operations.pydo not change. Dropped criteria:push_branch/push_tags, theGitOperationError/PushInfo mapping, the no-ref test, andrg -n '"push",' src/devops_cli/commands. - Not
CONST_GIT_NONINTERACTIVE_ENV. ItsGIT_SSH_COMMANDwould override a person'score.sshCommand. GIT_TERMINAL_PROMPT=0turns off only the terminal prompt. An askpass program the person configured (GIT_ASKPASS,core.askPassorSSH_ASKPASS, such as VS Code's) still runs, so the body's "both fail at once" holds only without one. ClearingGIT_ASKPASSas well is left to the owner.- Fetch included, and it fails closed. The release-branch fetch gets the same environment. A failed fetch now stops the cut with git's reason before any checkout, so a stale
origin/release/vX.Y.Zis never cut. This delivers fix(roadmap): the job clone tracks the current release's branch while origin has it and the default branch otherwise, so close, refine and metrics run between a ship and the next release's start #1366's "the cut's branch check fails closed" criterion. - Narrower tag push.
release tag --pushpushesrefs/tags/v<version>instead of--tags. - Names and branches.
_commit_and_push_release_branchis now_commit_and_push_cut_branch, and the cut branch isrelease/vX.Y.Z(feat(k8s): argo cd keeps the homelab cluster at the current release branch, with automated sync, prune and self-heal that never delete data #755). - What works now. From an agent's shell,
release prandrelease tag --pushauthenticate.release prepare --create-prand the automatic cut push a new commit torelease/vX.Y.Z. Therelease*ruleset refuses that push, so they now stop with GH013 instead of "could not read Username", until fix(roadmap): roadmap-service automated release cutting fails on protected release branch #1280. - Limit of the inherited environment. An exported
GIT_DIRorGIT_WORK_TREE(git exportsGIT_DIRto hooks in a linked worktree) points the release push and fetch at another repository: fix(release): an exported GIT_DIR never redirects the release command's push and fetch #1397. - Follow-ups found while building this. fix(release): an exported GIT_DIR never redirects the release command's push and fetch #1397, fix(security): mask_secrets masks every GitHub token prefix, ghu_, ghs_ and ghr_ included #1398 (
mask_secretsmissesghu_,ghs_andghr_tokens) and fix(cli): repos sync and branches sync report a failed fetch or pull instead of printing success #1399 (repos syncandbranches syncswallow fetch and pull errors).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 8, 2026
Moved to v0.2.29: v0.2.29 started with fewer than its 12 items and was topped up to 12 from Ready items, critical fixes and P0 features first. (devops roadmap reprioritize)
fix(release): run release pushes with the person's git environment (#…
dan-petty-bot commentedon Oct 8, 2026
What changed
#1402, merged into
release/v0.2.29as 8f287b5.5 file(s) changed.
How it was verified
Check runs at 3dd673d:
Acceptance Criteria of
docs/agent/tasks/task-1124-release-push-person-environment.md:The cut branch push (
_commit_and_push_cut_branch), the tag push (_push_git_tag) and the release-branch fetch (_fetch_remote_release_tip) runrun_subprocesswithisolate_env=FalseandGIT_TERMINAL_PROMPT=0. No other git call does (test_release_pr_command,test_release_notes_tag_and_check_extended).Environment test with real git on
tmp_path, a local bareoriginand no network (test_release_pr_pushes_in_the_persons_git_environment). The clone'spre-pushhook, run bydevops release pr, writes only the variables the test checks, and sees:!fake-helperfromgit config --get-all credential.https://example.com.helper;GIT_CONFIG_COUNT,GIT_CONFIG_KEY_0,GIT_CONFIG_VALUE_0,DBUS_SESSION_BUS_ADDRESS,REMOTE_CONTAINERS_IPCandSSH_AUTH_SOCKas the test set them;GIT_TERMINAL_PROMPT=0,GH_TOKENequal to the session's pinned token, and noGITHUB_TOKEN, although the environment set both to other values;fail_the_github_lookup), neitherGH_TOKENnorGITHUB_TOKEN.On the previous code the hook saw none of the person's variables and no prompt setting.
A rejected push exits 1 and never calls
gh. The error namesrelease/v0.2.26and carries git's reason as written, with the token in it masked (test_release_cut_rejected_push_stops_before_gh):release prepare --create-pr, refused by the bare remote'spre-receivehook. The error keeps git's[remote rejected].release pr, whose push repeats the remote tip, refused by the clone'spre-pushhook, which git runs even for an up-to-date push.A failed fetch stops the cut (
test_release_cut_stops_when_the_release_branch_fetch_fails). The remote has deletedrelease/v0.2.26and the clone still holdsorigin/release/v0.2.26.release prexits 1 with "Failed to fetch origin/release/v0.2.26" and git's reason, creates no cut branch, leaves the checkout on its branch, and never callsgh. A fetch that succeeds but writes noorigin/release/v<version>still stops with "does not exist" (test_release_cut_stops_when_the_fetch_writes_no_tracking_ref).release tag --pushpushesgit push origin refs/tags/v<version>and nothing else (test_release_notes_tag_and_check_extended). A refused tag push exits 1 with git's reason, the token in it masked, and closes no Release. A[/bold]in the reason is printed as text instead of raisingMarkupError(test_release_tag_push_and_errors).src/devops_cli/core/process.pyandsrc/devops_cli/git/operations.pydo not change, andtests/test_subprocess_env_boundary.pypasses unchanged.The new cases use local bare remotes, run no real helper and open no socket. Each takes well under 1 s.
uv run devops cipasses.Pending a person: in the devcontainer, on a local branch
try/push-check(git switch -c try/push-check), runsetsid -w uv run python -c "from pathlib import Path; from devops_cli.commands.release import _commit_and_push_cut_branch; _commit_and_push_cut_branch(Path('.'), 'try/push-check', '', commit=False)" < /dev/null. The push runs this repository's pre-commitpre-pushstage: whentry/push-checkcarries commits origin does not have yet, that stage runsuv run devops ci, and the push takes several minutes. The push succeeds without a prompt, andgit ls-remote origin try/push-checkshowsgit rev-parse HEAD. Then rungit push origin --delete try/push-check,git switch -andgit branch -D try/push-check.feat(release): v0.2.29 (#1455)