Skip to content

daemon: never let an internal git command wait on a credential prompt - #2459

Open
ugoenyioha wants to merge 1 commit into
git-ai-project:mainfrom
ugoenyioha:upstream-noninteractive
Open

ugoenyioha wants to merge 1 commit into
git-ai-project:mainfrom
ugoenyioha:upstream-noninteractive

Conversation

@ugoenyioha

@ugoenyioha ugoenyioha commented Oct 27, 2026 •

Copy link
Copy Markdown

Problem

The daemon inherits GIT_ASKPASS (and SSH_ASKPASS / core.askPass) from the shell that starts it, and so does every git it spawns. Coder workspaces and VS Code remote sessions set GIT_ASKPASS to a credential bridge. When a pull triggers the daemon's notes sync against an HTTPS remote with no stored credentials, git runs that askpass, which waits forever for a user who isn't there.

Each hung fetch holds one of the two command side-effect permits (COMMAND_SIDE_EFFECT_CONCURRENCY = 2). Two of them stall every family. All subsequent work queues in memory: on one workspace there were 10,688 stalled families, 77,327 queued entries and 47 GB RSS after 10 hours. The two fetches were stuck on Username for 'https://github.com'.

Fix

  • At startup the daemon sets GIT_TERMINAL_PROMPT=0, GIT_ASKPASS= (empty, which also stops git from falling back to core.askPass and SSH_ASKPASS) and GCM_INTERACTIVE=never, and removes SSH_ASKPASS, for itself and all its git children.
  • Notes fetch and push pass -c http.lowSpeedLimit=1024 -c http.lowSpeedTime=60, so a stalled server can't hold a permit indefinitely either.

Tests

  • daemon_git_env_fails_fast_on_credential_prompt: a local Basic-auth server plus an askpass that never answers. With the daemon's env, git fails at once and never runs the askpass. Removing the GIT_ASKPASS override, or the whole env, makes git hang and the test fail (mutation-checked).
  • authorship_fetch_and_push_args_abort_stalled_transfers.
  • cargo test --lib: all pass; notes_sync_regression 22 passed; integration notes/pull/fetch/push 168 passed.

Field check

On the affected workspace, a git pull from a credentialed server makes the daemon's notes fetch hit a 401:

  • The fixed daemon fails fast.
  • The previous binary, run in an isolated home, leaves git-remote-http blocked on the askpass.

Devin Review

The daemon inherited GIT_ASKPASS from the shell that started it (a Coder
workspace sets it to its own credential bridge). A notes fetch from an
HTTPS remote with no stored credentials ran that askpass program, which
waited forever for a user. The fetch held one of the two command
side-effect permits; the second hang took the other. Every family's
queued side effects then accumulated in memory: 10,688 stalled families
and 47 GB RSS after 10 hours on one workspace.

- The daemon sets GIT_TERMINAL_PROMPT=0, GIT_ASKPASS='' (which also
  disables core.askPass and SSH_ASKPASS) and GCM_INTERACTIVE=never, and
  drops SSH_ASKPASS, for itself and every git it spawns.
- Notes fetch and push abort an HTTP transfer slower than 1 KiB/s for
  60 s instead of waiting on a stalled server.

Tests: a local Basic-auth server plus an askpass program that never
answers; the test fails (git hangs) when either the GIT_ASKPASS override
or the whole environment is removed.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment thread src/daemon.rs
/// fetch blocked forever and stalled every family queued behind it.
#[cfg(unix)]
#[test]
fn daemon_git_env_fails_fast_on_credential_prompt() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Daemon credential protection remains untested

If run_daemon omits make_git_noninteractive_for_daemon_process, this test still passes because it applies the constants directly. No TestRepo-based test covers the startup path, contrary to the repository's testing rule.

Learn more

The test builds a separate git ls-remote command and applies the same constants as the implementation. It does not exercise run_daemon, which is responsible for setting them in the daemon process. A regression that removes the startup call still passes the new test. The repository's integration-testing rule requires high-quality TestRepo-based coverage for Git behavior.

Example: Remove the make_git_noninteractive_for_daemon_process() call from daemon startup. The test still sets GIT_ASKPASS to an empty string on its own command and passes, even though a real daemon inherits an interactive askpass.

Recommended fix: Add a TestRepo-based integration test that starts a daemon with a hanging inherited askpass, runs a Git operation that triggers notes sync against a local authentication-challenging remote, and asserts the daemon finishes without launching askpass.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
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