{"record":{"id":"4b23b69b52dc5d62","repo":"windmill-labs/windmill","slug":"failed-to-get-branch-from-git-repo-resource-pleas","errorCode":null,"errorMessage":"Failed to get branch from git repo resource, please check that the resource has the correct type (git_repository)","messagePattern":"Failed to get branch from git repo resource, please check that the resource has the correct type \\(git_repository\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-worker/src/ansible_executor.rs","lineNumber":1739,"sourceCode":"                )\n                .await?\n            else {\n                return Err(windmill_common::error::Error::BadRequest(\n                    \"Git repository resource is not an object\".to_string(),\n                ));\n            };\n\n            let secret_url = git_repo_resource.get(\"url\").and_then(|s| s.as_str()).map(|s| s.to_string())\n                .ok_or(anyhow!(\"Failed to get url from git repo resource, please check that the resource has the correct type (git_repository)\"))?;\n\n            #[cfg(feature = \"enterprise\")]\n            let is_github_app = git_repo_resource.get(\"is_github_app\").and_then(|s| s.as_bool())\n                .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)\"))?;\n            #[cfg(not(feature = \"enterprise\"))]\n            let is_github_app = false;\n\n            let branch = Some(git_repo_resource.get(\"branch\").and_then(|s| s.as_str()).map(|s| s.to_string())\n                .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());\n\n            let target_path = DELEGATE_GIT_REPO_TARGET.to_string();\n\n            let repo = GitRepo {\n                url: secret_url,\n                commit: interpolated_commit.clone(),\n                branch,\n                target_path,\n            };\n            append_logs(\n                &job.id,\n                &job.workspace_id,\n                format!(\"\\nCloning {}...\\n\", delegated_git_repo.resource),\n                conn,\n            )\n            .await;\n            if is_github_app {\n                // An app-backed repo's URL carries no credential, so git can't","sourceCodeStart":1721,"sourceCodeEnd":1757,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-worker/src/ansible_executor.rs#L1721-L1757","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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\")."],"exampleFix":"// resource payload\n// before\n{ \"url\": \"https://github.com/org/repo.git\", \"is_github_app\": false }\n// after\n{ \"url\": \"https://github.com/org/repo.git\", \"is_github_app\": false, \"branch\": \"main\" }","handlingStrategy":"validation","validationCode":"if (typeof r.branch !== 'string' || r.branch.length === 0) {\n  throw new Error('git_repository resource must include a string branch');\n}","typeGuard":"function hasBranch(v: unknown): v is { branch: string; [k: string]: unknown } {\n  return typeof v === 'object' && v !== null && typeof (v as any).branch === 'string';\n}","tryCatchPattern":"try {\n  const branch = resource.branch;\n} catch (e) {\n  throw new Error('add a branch field to the git_repository resource');\n}","preventionTips":["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"],"tags":["validation","resources","git"],"backgroundTag":"missing-resource-field","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"}