Skip to content

Fix Git sync when server-spawned Git needs SSH or credential-helper env#310

Open
ron-ulitsky wants to merge 2 commits into
inkeep:mainfrom
ron-ulitsky:fix-preserve-git-ssh-env
Open

Fix Git sync when server-spawned Git needs SSH or credential-helper env#310
ron-ulitsky wants to merge 2 commits into
inkeep:mainfrom
ron-ulitsky:fix-preserve-git-ssh-env

Conversation

@ron-ulitsky

Copy link
Copy Markdown

Git auto-sync now preserves the environment Git needs to authenticate when the server fetches or pushes a repository.

The server previously spawned Git with a small environment. That worked for token-backed HTTPS paths, but it broke remotes that depend on the user's home directory, SSH agent, or credential-helper environment. On Windows with an SSH remote, ok sync and editor sync could fail with:

fatal: Could not read from remote repository.

The same git fetch or git push worked from a terminal.

This change keeps the user/home/session variables Git uses to locate SSH keys, SSH agents, and credential helpers. Commit author/committer overrides now merge into that preserved environment, so auto-save commits do not drop auth state before push.

GIT_TERMINAL_PROMPT=0 and locale-stable stderr behavior stay unchanged. GIT_SSH_COMMAND still does not pass through without simple-git's explicit unsafe opt-in.

Testing:

  • npx -y bun@1.3.13 test packages/server/src/git-handle.test.ts
  • git diff --check
  • Fresh Linux container clone of this branch:
    • bun install --frozen-lockfile
    • bun run lint

Manual verification on Windows:

  • reproduced the failure with a stripped server-style Git environment
  • rebuilt this branch and verified ok sync --json succeeds against an SSH remote
  • confirmed sync returns to idle with consecutiveFailures: 0

Notes:

  • bun run check in a fresh Linux container hit existing upstream failures. The same sync-engine.test.ts failures reproduce on inkeep/open-knowledge@main, so they are not introduced by this branch.

@CLAassistant

CLAassistant commented Jun 26, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown

I could not sync this public PR into agents-private automatically.

Patch application failed. The diff could not be applied cleanly. Try rebasing your PR on the latest base branch.

Falling back to direct application...
Applied patch to 'public/open-knowledge/packages/server/src/git-handle.test.ts' cleanly.
Applied patch to 'public/open-knowledge/packages/server/src/git-handle.ts' with conflicts.
Applied patch to 'public/open-knowledge/packages/server/src/sync-engine.ts' with conflicts.
U public/open-knowledge/packages/server/src/git-handle.ts
U public/open-knowledge/packages/server/src/sync-engine.ts

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.

2 participants