windmill-labs/windmill · error
Failed to get branch from git repo resource, please check th
Error message
Failed to get branch from git repo resource, please check that the resource has the correct type (git_repository)
What it means
handle_ansible_job requires the git_repository resource to include a string `branch` field (later filtered for empty strings). A missing or non-string `branch` makes the worker unable to construct the GitRepo to clone, so it throws this error.
Source
Thrown at backend/windmill-worker/src/ansible_executor.rs:1739
)
.await?
else {
return Err(windmill_common::error::Error::BadRequest(
"Git repository resource is not an object".to_string(),
));
};
let secret_url = git_repo_resource.get("url").and_then(|s| s.as_str()).map(|s| s.to_string())
.ok_or(anyhow!("Failed to get url from git repo resource, please check that the resource has the correct type (git_repository)"))?;
#[cfg(feature = "enterprise")]
let is_github_app = git_repo_resource.get("is_github_app").and_then(|s| s.as_bool())
.ok_or(anyhow!("Failed to get `is_github_app` field from git repo resource, please check that the resource has the correct type (git_repository)"))?;
#[cfg(not(feature = "enterprise"))]
let is_github_app = false;
let branch = Some(git_repo_resource.get("branch").and_then(|s| s.as_str()).map(|s| s.to_string())
.ok_or(anyhow!("Failed to get branch from git repo resource, please check that the resource has the correct type (git_repository)"))?).filter(|s| !s.is_empty());
let target_path = DELEGATE_GIT_REPO_TARGET.to_string();
let repo = GitRepo {
url: secret_url,
commit: interpolated_commit.clone(),
branch,
target_path,
};
append_logs(
&job.id,
&job.workspace_id,
format!("\nCloning {}...\n", delegated_git_repo.resource),
conn,
)
.await;
if is_github_app {
// An app-backed repo's URL carries no credential, so git can'tView on GitHub (pinned to e474e8803c)
Solutions
- Edit the resource and add `"branch": "<branch-name>"` as a string.
- Verify the resource type is git_repository and its payload matches the current schema.
- Re-save via the UI's git resource form so defaults are populated.
- If the repo default branch is intended, explicitly set it (e.g. "main").
Example fix
// resource payload
// before
{ "url": "https://github.com/org/repo.git", "is_github_app": false }
// after
{ "url": "https://github.com/org/repo.git", "is_github_app": false, "branch": "main" } Defensive patterns
Strategy: validation
Validate before calling
if (typeof r.branch !== 'string' || r.branch.length === 0) {
throw new Error('git_repository resource must include a string branch');
} Type guard
function hasBranch(v: unknown): v is { branch: string; [k: string]: unknown } {
return typeof v === 'object' && v !== null && typeof (v as any).branch === 'string';
} Try / catch
try {
const branch = resource.branch;
} catch (e) {
throw new Error('add a branch field to the git_repository resource');
} Prevention
- Always set an explicit branch when creating git resources
- Use the UI form rather than raw JSON for resource creation
- Validate imported resources against the git_repository schema
When it happens
Trigger: An ansible job's git-repo dependency resource has no `branch` field or a non-string value, so the branch cannot be read when building the clone configuration.
Common situations: Resource JSON edited by hand without `branch`; branch stored as null; resource created for a different type; UI versions disagreeing on optional-vs-required branch.
Related errors
- Failed to get url from git repo resource, please check that
- Failed to get `is_github_app` field from git repo resource,
- result.substring(__RESULT_ERR_PREFIX.length)
- Invalid migration name '${name}': use only letters, digits,
- Unknown workspace dependencies file format: ${path}. Valid f
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/4b23b69b52dc5d62.
Report an issue: GitHub.