windmill-labs/windmill · error

Failed to clone git repo `{}`: {e}

Error message

Failed to clone git repo `{}`: {e}

What it means

When cloning an ansible job's git-repo dependency fails, handle_ansible_job wraps the underlying error and re-raises it with the sanitized (credential-stripped) repo URL. The inner error `e` carries the actual git failure (auth, network, ref not found).

Source

Thrown at backend/windmill-worker/src/ansible_executor.rs:1790

                )
                .await?;
            } else if let Some(commit) = interpolated_commit.as_ref() {
                clone_repo_without_history(
                    &repo,
                    commit,
                    job_dir,
                    &job.id,
                    worker_name,
                    conn,
                    mem_peak,
                    canceled_by,
                    &job.workspace_id,
                    occupancy_metrics,
                    git_ssh_cmd,
                )
                .await
                .map_err(|e| {
                    anyhow!(
                        "Failed to clone git repo `{}`: {e}",
                        sanitize_git_url(&repo.url)
                    )
                })?;
            } else {
                clone_repo(
                    &repo,
                    job_dir,
                    &job.id,
                    worker_name,
                    conn,
                    mem_peak,
                    canceled_by,
                    &job.workspace_id,
                    occupancy_metrics,
                    git_ssh_cmd,
                )
                .await

View on GitHub (pinned to e474e8803c)

Solutions

  1. Inspect the wrapped inner error (`: {e}` part) for the precise git failure.
  2. Verify/renew the credentials on the git_repository resource (token or SSH key).
  3. Confirm the pinned branch/commit still exists on the remote.
  4. Test the clone manually from the worker with the same GIT_SSH_CMD.
  5. Check worker egress/proxy and known_hosts configuration for private hosts.

Example fix

// workspace git credentials: rotate token
// before
GIT_TOKEN=ghp_expired...
// after
GIT_TOKEN=ghp_newlyGeneratedToken  // then update the git_repository resource to use fresh credentials
Defensive patterns

Strategy: retry

Validate before calling

// preflight clone reachability before running the job:
git ls-remote "$REPO_URL" "$BRANCH" >/dev/null 2>&1 && echo OK || echo 'repo/branch not clonable with current credentials'

Try / catch

match clone_repo_with_ssh_cmd(...).await {
    Ok(()) => {},
    Err(e) => {
      log::error!("Failed to clone git repo `{}`: {e:#}", sanitize_git_url(&repo.url));
      // retry with backoff for transient network errors; surface auth errors to the user
    }
}

Prevention

When it happens

Trigger: get_repo (or clone path with git_ssh_cmd) invoked for a dependency repo returns Err — bad credentials, unknown revision/branch, unreachable host — during handle_ansible_job's dependency setup.

Common situations: Expired PAT or GitHub App token; SSH deploy key missing on worker or not in known_hosts; branch/commit pinned in the job no longer exists; private repo with no egress or proxy misconfig.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/7a8cdd1b17651d47. Report an issue: GitHub.