{"record":{"id":"911da1ea2424f714","repo":"windmill-labs/windmill","slug":"error-getting-git-repo-commit-hash-stderr","errorCode":null,"errorMessage":"Error getting git repo commit hash: {stderr}","messagePattern":"Error getting git repo commit hash: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-worker/src/ansible_executor.rs","lineNumber":376,"sourceCode":"    let mut rev_parse_cmd = Command::new(GIT_PATH.as_str());\n\n    let commit_hash_output = rev_parse_cmd\n        .current_dir(job_dir)\n        .env_clear()\n        .envs(PROXY_ENVS.clone())\n        .env(\"PATH\", PATH_ENV.as_str())\n        .env(\"TZ\", TZ_ENV.as_str())\n        .env(\"GIT_SSH_COMMAND\", git_ssh_cmd)\n        .arg(\"-C\")\n        .arg(&target_path)\n        .args([\"rev-parse\", \"HEAD\"])\n        .stderr(Stdio::piped())\n        .output()\n        .await?;\n\n    if !commit_hash_output.status.success() {\n        let stderr = String::from_utf8(commit_hash_output.stderr)?;\n        return Err(anyhow!(\"Error getting git repo commit hash: {stderr}\").into());\n    }\n\n    let commit_hash = String::from_utf8(commit_hash_output.stdout)?\n        .trim()\n        .to_string();\n\n    Ok(commit_hash)\n}\n\npub fn create_empty_dir(path: &PathBuf) -> std::io::Result<()> {\n    if path.exists() {\n        if path.is_dir() {\n            let mut entries = std::fs::read_dir(&path)?;\n            if entries.next().is_some() {\n                return Err(std::io::Error::new(\n                    std::io::ErrorKind::AlreadyExists,\n                    format!(\n                        \"Directory '{}' already exists and is not empty\",","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-worker/src/ansible_executor.rs#L358-L394","documentation":"In clone_repo, after running `git rev-parse` (or similar) to get the repository commit hash, the command exited non-zero. The stderr is embedded so the underlying git failure (missing repo, auth failure, bad ref) is visible.","triggerScenarios":"Ansible job requires a git repo; the git command to read the commit hash fails — repo not cloned yet, wrong branch/tag, bad credentials, or git not installed in the worker image.","commonSituations":"Private repo without deploy key/token; repo URL typo; worker image missing git binary; network egress blocked from the worker.","solutions":["Read the stderr in the message — it names the git failure","Verify the repo URL, branch/tag and credentials (deploy key or token) are correct","Test `git ls-remote <url>` from the worker environment","Ensure git is installed in the worker image and egress to the git host is allowed"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"git ls-remote \"$REPO_URL\" \"$BRANCH\" >/dev/null 2>&1 || echo \"repo/branch not reachable\"\ncommand -v git >/dev/null || echo \"git missing in worker image\"","typeGuard":null,"tryCatchPattern":"// retry transient git failures before failing the job\nfor attempt in 0..3 {\n    match clone_repo(...).await {\n        Err(e) if e.to_string().contains(\"commit hash\") && attempt < 2 => {\n            tokio::time::sleep(Duration::from_secs(2u64.pow(attempt))).await;\n        }\n        other => { other?; break; }\n    }\n}","preventionTips":["Verify repo URL/branch and deploy credentials before the job","Test git access from the worker network (egress/proxy)","Ensure git is installed in the worker image","Pre-clone warm repos to surface auth issues early"],"tags":["rust","git","ansible","subprocess"],"backgroundTag":"git-command-failed","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}