Skip to content

fix(clawdbot): wire GITHUB_PAT into git credential.helper at postStart - #414

Closed
samxu01 wants to merge 1 commit into
mainfrom
fix/clawdbot-git-credentials
Closed

samxu01 wants to merge 1 commit into
mainfrom
fix/clawdbot-git-credentials

Conversation

@samxu01

@samxu01 samxu01 commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

PR #382 plumbed GITHUB_PAT into the clawdbot-gateway env var but never wired it into git. The env is present (verified: 93 chars), but every git clone https://... from inside the pod (subagents, acpx_run, operator kubectl exec) fails with:

fatal: could not read Username for 'https://github.com'

Repro (from 2026-05-20 smoke cycle 10)

Theo (openclaw:theo) was asked to clone Team-Commonly/clawdbot to investigate the heartbeat-clobber bug. Got the unauthenticated-clone error. Without git credentials, openclaw agents can never git clone / git push / gh against private repos — blocks any agent-driven repo metadata work.

Fix

Extend the existing lifecycle.postStart hook (already used for the codex auth.json copy) to ALSO write a git credential.helper config when GITHUB_PAT is set. Mirrors the cloud-codex boot script's wiring (both runtimes consistent):

  • trim trailing newline/CR (libcurl rejects PATs with newlines — verified empirically on cloud-codex 2026-05-15)
  • write /state/.git-credentials (0600, persists on PVC)
  • point git config --global credential.helper at that file
  • set author identity to Clawdbot Agent <[email protected]>

Silent no-op when GITHUB_PAT is empty — keeps community-tier deployments safe.

Idempotent — repeated postStart invocations rewrite the same content.

Test plan

  • Chart Lint passes (CI)
  • After deploy: kubectl exec -n commonly-dev deploy/clawdbot-gateway -- git clone https://github.com/Team-Commonly/commonly /tmp/t succeeds without prompting
  • Manual: ask a moltbot agent (e.g. Nova) to do an acpx_run -> gh issue list --repo Team-Commonly/commonly and verify real output (not auth error)

🤖 Generated with Claude Code

PR #382 plumbed GITHUB_PAT into the clawdbot-gateway env (verified: env
var present, length matches the api-keys secret). What it did NOT do is
wire the credential helper, so every `git clone https://...` from
within the pod (subagent / acpx / operator `kubectl exec`) hits:
  `fatal: could not read Username for 'https://github.com'`

Surfaced 2026-05-20 smoke cycle 10: Theo tried to clone
Team-Commonly/clawdbot to investigate the heartbeat-clobber bug — got
the unauthenticated-clone error even though GITHUB_PAT was in env.

Fix: extend the existing lifecycle.postStart hook (already used for
the codex auth.json copy) to ALSO write a credential helper config
when GITHUB_PAT is set. Mirrors the cloud-codex boot script's wiring
so both runtimes are consistent:
  - trim trailing newline / CR (libcurl rejects PATs with newlines)
  - write `/state/.git-credentials` (0600, persists on the PVC)
  - point git's credential.helper at that file globally
  - set git author identity to Clawdbot Agent / [email protected]

Silent no-op when GITHUB_PAT is empty — keeps the hook safe for
community-tier deployments that ship no PAT by design.

Idempotent — repeated postStart invocations (on container restart)
overwrite the same file with the same content.
@samxu01 samxu01 closed this in 43c5c01 May 21, 2026
samxu01 added a commit that referenced this pull request May 22, 2026
Reviewer on PR #414 asked: are GIT_AUTHOR_NAME / GIT_AUTHOR_EMAIL
expected to be set externally, or should they be defined in the
deployment template like GITHUB_PAT is?

Answer: there is currently no per-agent author override flowing
through Helm values. The shell fallbacks
('Clawdbot Agent' / '[email protected]') are the intended
default. If operators want to override later — e.g. per-instanceId
author for clearer commit attribution — they can either:
  - add them to the env: block as plain value: entries, OR
  - wire them through values.yaml as .Values.agents.clawdbot.git.*

Either path is one small follow-up PR. Documenting the intent
inline so the next reader doesn't have to re-derive it.

No behavioral change.
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.

1 participant