Skip to content

fix(git): allow opting into a non-interactive askpass helper - #24105

Open
nateEc wants to merge 8 commits into
pingdotgg:mainfrom
nateEc:codex/fix-23044-preserve-git-askpass
Open

nateEc wants to merge 8 commits into
pingdotgg:mainfrom
nateEc:codex/fix-23044-preserve-git-askpass

Conversation

@nateEc

@nateEc nateEc commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem and scope

Fixes https://git.cafe/pingdotgg/t3code/issues/23044. T3 deliberately clears askpass variables during background and workspace-preparation fetches to avoid interactive prompts. In environments such as Coder, an inherited GIT_ASKPASS can instead be the existing non-interactive credential source; clearing it makes worktree preparation fail before the agent starts.

This is a focused configuration option for an established capability under CONTRIBUTING.md: no new credential store, provider, workflow, or default change. Set T3CODE_GIT_PRESERVE_ASKPASS=1 in the server environment to preserve its inherited Git askpass helper for both fetch paths. Unset/other values retain today's behavior. Terminal prompting, GCM interaction, and SSH askpass remain disabled. Documentation warns that the operator must choose a trusted non-interactive helper; T3 cannot stop an opted-in helper from opening its own dialog.

Git documents askpass independently of terminal prompting in gitcredentials and GIT_TERMINAL_PROMPT.

Verification

The new integration test uses real Git, a throwaway repository, a loopback HTTP endpoint requiring fixture-only Basic credentials, and a disposable askpass script. Repository configuration disables the developer's credential helpers and proxy. No real credentials or external repository are used.

  • Before: the opted-in fetch still failed with Git could not authenticate with the remote (exit 128).
  • After: default fetch fails without invoking the helper; opt-in fetch succeeds and stores the expected remote commit; explicit 0 disables the helper again. The existing background-fetch environment test now covers both opt-in states and verifies that the other four non-interactive controls stay unchanged.
  • vp test run apps/server/src/vcs/GitVcsDriverCore.test.ts: all 165 tests pass via check:changed.
  • vp run check:changed: formatting, lint, knip, GraphQL validation, scoped typechecks, and the affected test file all pass. Existing unrelated lint warnings remain unchanged.
  • Tested on macOS arm64, Node 26.12.1, Git 2.50.1. The real helper integration is POSIX-only and skipped on Windows. No native Windows or actual Coder deployment claim.

This is server-side fetch configuration; no web, desktop, or mobile rendering changes or UI screenshots are needed. All clients that request workspace preparation use the same server path.

Model: GPT-5-based Codex. Harness: Codex desktop app.

Fixes #23044

- 新增服务端环境开关,让后台和工作区准备 fetch 可保留继承的 GIT_ASKPASS,默认行为不变。
- 保持终端提示、Git Credential Manager 交互及 SSH askpass 禁用,并说明可信助手的适用范围。
- 通过真实 Git 与隔离 HTTP 认证测试验证开启、默认和关闭路径;165 项模块测试及 check:changed 通过。
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Oct 23, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at d659634

Macroscope's review found this PR approvable — Adds an explicit opt-in for background and workspace Git fetches to retain a server-configured credential helper. Existing defaults and other prompt restrictions remain unchanged, with documentation requiring a non-interactive helper.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The server adds T3CODE_GIT_PRESERVE_ASKPASS for background status fetches and remote fetches. When set to "1", the fetch environment retains the inherited GIT_ASKPASS; otherwise, it uses the existing non-interactive environment.

Changes: Git askpass refresh environment

Layer / File(s) Summary
Refresh environment, fetch coverage, and documentation
apps/server/src/vcs/GitVcsDriverCore.ts, apps/server/src/vcs/GitVcsDriverCore.test.ts, docs/user/source-control.md
When the setting is "1", the refresh environment retains the inherited GIT_ASKPASS value, or uses an empty string if it is unset. Background status fetches and remote fetches use this environment. Tests cover both setting values and verify the non-interactive prompt settings. The documentation describes the setting and limits its use to helpers that do not open dialogs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature · Severity of issue fixed: Medium

Possibly related PRs

  • pingdotgg/t3code#32312: Renames the environment constant used by status refresh and fetchRemote; both changes modify the environment contract in GitVcsDriverCore.ts.
  • pingdotgg/t3code#34042: Removes fetchRemote, a code path changed and tested by this PR.

Suggested reviewers: juliusmarminge, maria-rcks

Merge Risk: Minimal · up to 13f0b

This adds an opt-in server setting that keeps a non-interactive Git askpass helper for background and workspace-preparation fetches. Default behavior is unchanged, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a server option that lets operators opt into an inherited non-interactive GIT_ASKPASS helper for git fetches. It follows conventional commit format and is specific. Th…
Description check Passed The description follows the template's sections and fills in Problem, Change, Scope, and Verification. It explains the Coder-related problem, the opt-in env var, and why the change is a bug fix for an…
Linked Issues check Passed [#23044] The reviewed head defines upstreamRefreshEnvironment in apps/server/src/vcs/GitVcsDriverCore.ts. It keeps the inherited GIT_ASKPASS only when `HostProcess.Environment.T3CODE_GIT_PRESERV…
Out of Scope Changes check Passed [#23044] The production change is limited to the upstreamRefreshEnvironment selector. It adds the T3CODE_GIT_PRESERVE_ASKPASS opt-in and passes GIT_ASKPASS through only in that case. The test ch…
Full details: Title check

Explanation

The title names the main change: a server option that lets operators opt into an inherited non-interactive GIT_ASKPASS helper for git fetches. It follows conventional commit format and is specific. The changeset matches it: T3CODE_GIT_PRESERVE_ASKPASS preserves GIT_ASKPASS in upstreamRefreshEnvironment, with tests and docs.

Full details: Description check

Explanation

The description follows the template's sections and fills in Problem, Change, Scope, and Verification. It explains the Coder-related problem, the opt-in env var, and why the change is a bug fix for an existing capability, and links issue #23044. Verification gives concrete before/after results, test counts, platform, and untested areas. The template's optional closing note on the agent model and harness is present. The Change section is brief and the template's scope rule asks for a note on any maintainer request, but these gaps are minor.

Full details: Linked Issues check

Explanation

[#23044] The reviewed head defines upstreamRefreshEnvironment in apps/server/src/vcs/GitVcsDriverCore.ts. It keeps the inherited GIT_ASKPASS only when HostProcess.Environment.T3CODE_GIT_PRESERVE_ASKPASS === "1". Otherwise it returns STATUS_UPSTREAM_REFRESH_ENV, which sets GIT_ASKPASS: "". The opt-in copies the other four controls unchanged: GCM_INTERACTIVE=never, GIT_TERMINAL_PROMPT=0, SSH_ASKPASS="", and SSH_ASKPASS_REQUIRE=never. This matches the issue's default-preserving, opt-in, and prompting-disabled criteria. The previous assessment reports that background status refreshes and fetchRemote both use this environment, and the test changes cover both states for both paths. I did not inspect the test file or fetchRemote call sites in this pass, so that coverage rests on the prior assessment and the summaries. Documentation in docs/user/source-control.md covers the option and the trusted non-dialog helper requirement. The Linux VM, Coder, and Windows results are author-reported and were not re-run. Merge-of-main test adaptations do not change the requirement outcome.

Full details: Out of Scope Changes check

Explanation

[#23044] The production change is limited to the upstreamRefreshEnvironment selector. It adds the T3CODE_GIT_PRESERVE_ASKPASS opt-in and passes GIT_ASKPASS through only in that case. The test changes in GitVcsDriverCore.test.ts verify both option states and the unchanged non-interactive controls. The documentation change describes the option and its trust requirement. The summaries show no changes to exported declarations, API surfaces, or UI. The objectives mention test-import adaptation, an obsolete import removal, and a TMPDIR adjustment. These are test-maintenance items and do not appear as unrelated production changes. The test-file content was not read in this pass, so that conclusion relies on the summaries.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d659634 and 13f0bd5.

Files selected for processing: 3

  • apps/server/src/vcs/GitVcsDriverCore.test.ts
  • apps/server/src/vcs/GitVcsDriverCore.ts
  • docs/user/source-control.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Oct 31, 2026

maria-rcks commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Note

Written by claude-opus-5-5 on behalf of Maria

merged current main (67eebaca23) into the original branch at b34f69285a, without rebasing. the production fix and docs are unchanged.

one conflict, in GitVcsDriverCore.test.ts: main moved the background-fetch test from mutating process.env to providing HostProcess.Environment. the resolution keeps this PR's preserve askpass: false/true cases in main's style. the authenticated fetch test now also spreads the host environment, since the git child env is now built from HostProcess.Environment and would otherwise lose PATH.

verification:

  • blacksmith vp test run apps/server/src/vcs/GitVcsDriverCore.test.ts: 239 passed, including the 3 askpass cases.
  • blacksmith vp run check:changed against main: format, lint, knip, graphql, typecheck (3 packages), and 241 tests pass.

earlier verification from the prior round (real dev server, private https remote, codex turn) still describes the unchanged production code. unverified: native windows and an actual coder deployment.

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

Verified in a real dev environment

verified as-is at c3b9eb77544f0f9a2c6db227864243e2ee14dec2 on a disposable linux vm. installed main and the exact pr head with vp i, and ran their real dev servers sequentially with isolated state. drove the web app using the repository’s playwright and /usr/bin/google-chrome. no mocks, fixtures, replay provider, or seeded data.

added a project through the app pointing at a real private github repository with configured credential helpers disabled and a trusted inherited askpass helper. selected codex gpt-6.1-sol, new worktree, and “from main (remote)”.

  • github/main (80a2351fcb) with the option enabled: workspace fetch failed with “git could not authenticate with the remote”; the helper was never invoked and the provider never started.
  • exact pr head with T3CODE_GIT_PRESERVE_ASKPASS=1: authenticated fetch and worktree creation succeeded. a real codex turn read the readme and returned the worktree branch and expected commit. no files changed.
  • neighboring current-checkout flow: a second real codex turn ran git status and rev-parse, reporting a clean checkout and the expected commit.
  • background refresh: subsequent helper invocations occurred against the real https remote while no workspace preparation was running. helper logs confirmed GIT_TERMINAL_PROMPT=0, GCM_INTERACTIVE=never, empty SSH_ASKPASS, and SSH_ASKPASS_REQUIRE=never.
  • restarted with the option unset: workspace fetch failed again with zero helper invocations. re-enabled it, restarted, and clicked retry on that failed thread: worktree creation and a real codex turn completed successfully.
  • blacksmith ran vp i && vp test run apps/server/src/vcs/GitVcsDriverCore.test.ts: all 200 tests passed. existing head ci reports 32 successful checks. no source changes or pushes were needed.

main, same repository and prompt:

main fails authenticated workspace preparation

pr, same repository and prompt:

pr creates worktree and completes real codex turn

retrying the failed thread after re-enabling the option:

retry provisions the worktree and completes codex turn

Not verified

native desktop, ios/android, macos/windows, and an actual coder deployment were not exercised on this linux vm. the real provider path covered codex only. ssh interactive prompting was not attempted; its disabled environment was observed. the recording shows the interaction sequence, not a performance measurement.

…rve-git-askpass

# Conflicts:
#	apps/server/src/vcs/GitVcsDriverCore.test.ts
@macroscopeapp
macroscopeapp Bot dismissed their stale review November 5, 2026 05:05

Dismissing prior approval to re-evaluate b34f692

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Nov 5, 2026
- 合并主线的 Git 路径处理改动,保留现有凭据助手测试。
- 解决测试导入冲突,不改写维护者已有提交。

nateEc commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged main e455200 into this branch in 4369f5d, preserving the maintainer's askpass fixes and verification history. Resolved the test-import conflict with main's path handling and removed the obsolete NodeOS import. check:changed passed (format, lint, both knip checks, GraphQL, three affected-package typechecks, and 242 tests in two files). On macOS the first run exposed an unrelated main test comparing Git's canonical /private path against /var; the successful run used canonical TMPDIR=/private/tmp without changing production code or weakening that test. Earlier private-HTTPS/askpass verification remains linked in the PR description.

…rve-git-askpass

# Conflicts:
#	apps/server/src/vcs/GitVcsDriverCore.test.ts
Replace the HTTP-server integration test with a fetchRemote assertion in
the existing environment-log test, and tighten the user docs paragraph.

AI-assisted; verified with the tests and tools listed above.
@macroscopeapp
macroscopeapp Bot dismissed their stale review November 12, 2026 22:07

Dismissing prior approval to re-evaluate d659634

@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Real web client and server; Chromium, 1280×800, light theme, fresh databases, synthetic private HTTPS remote. Both servers inherit the same non-interactive askpass helper with T3CODE_GIT_PRESERVE_ASKPASS=1. Select New worktree → From main (remote) and send the same replay request.

Before After
39ab6a2d2f d659634002
Before: Git authentication fails during workspace preparation After: remote worktree is created and replay turn completes
Before recording After recording

The comparison exited 0: base fails and head passes. Restarting head with the option unset restores the authentication failure: control recording.

Head control: authentication fails with the option unset

Scenario · HTTPS fixture · Driver · Proof JSON

Filesystem prefixes are redacted; the head recording masks a read-tool row containing internal paths. Its branch-naming warning comes from disabling generated naming in the fixture and does not prevent worktree preparation or agent completion.

AI-assisted; verified with the tests and tools listed above.

Not shown:

  • Values other than '1' and unset were not exercised.
  • Background-fetch status behavior was not separately demonstrated with a dedicated capture.
  • The reproduction used a synthetic authenticated HTTPS remote rather than an actual Coder workspace.

保留本 PR 的行为和回归覆盖。

合并主线上相关的接口和测试更新。

nateEc commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow preserving GIT_ASKPASS for Coder authentication during workspace creation

3 participants