{"record":{"id":"3cb25accecfc9598","repo":"argoproj/argo-workflows","slug":"single-branch-mode-without-a-branch-specified","errorCode":null,"errorMessage":"single branch mode without a branch specified","messagePattern":"single branch mode without a branch specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/artifacts/git/git.go","lineNumber":126,"sourceCode":"\t\ttransport.UnsupportedCapabilities = newCaps\n\t}\n\n\tsshUser := GetUser(a.Repo)\n\tcloser, auth, err := g.auth(sshUser)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer closer()\n\tdepth := a.GetDepth()\n\tcloneOptions := &git.CloneOptions{\n\t\tURL:             a.Repo,\n\t\tAuth:            auth,\n\t\tDepth:           depth,\n\t\tSingleBranch:    a.SingleBranch,\n\t\tInsecureSkipTLS: g.InsecureSkipTLS,\n\t}\n\tif a.SingleBranch && a.Branch == \"\" {\n\t\treturn errors.New(\"single branch mode without a branch specified\")\n\t}\n\tif a.SingleBranch {\n\t\tcloneOptions.ReferenceName = plumbing.NewBranchReferenceName(a.Branch)\n\t}\n\n\tr, err := git.PlainClone(path, false, cloneOptions)\n\tif errors.Is(err, transport.ErrEmptyRemoteRepository) {\n\t\tlogging.RequireLoggerFromContext(ctx).Info(ctx, \"Cloned an empty repository\")\n\t\tvar initErr error\n\t\tr, initErr = git.PlainInit(path, false)\n\t\tif initErr != nil {\n\t\t\treturn fmt.Errorf(\"failed to plain init: %w\", initErr)\n\t\t}\n\t\tif _, remoteErr := r.CreateRemote(&config.RemoteConfig{Name: git.DefaultRemoteName, URLs: []string{a.Repo}}); remoteErr != nil {\n\t\t\treturn fmt.Errorf(\"failed to create remote %q: %w\", a.Repo, remoteErr)\n\t\t}\n\t\tbranchName := a.Revision\n\t\tif branchName == \"\" {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/artifacts/git/git.go#L108-L144","documentation":"The git artifact driver refuses to clone when `singleBranch: true` is set on the artifact but no `branch` is specified. Single-branch mode tells go-git to fetch only one branch's history, so a branch name is mandatory to know which ref to clone. This is an upfront configuration validation, thrown before any network I/O.","triggerScenarios":"Calling Load() on a git artifact whose spec sets `singleBranch: true` while `branch` is empty/omitted.","commonSituations":"Users set singleBranch to speed up clones of large repos but forget to name the branch; templates that parameterize branch (e.g. `branch: '{{workflow.parameters.branch}}'`) where the parameter resolves to an empty string.","solutions":["Set the `branch` field on the git artifact, e.g. `branch: main`, whenever `singleBranch: true`.","If the branch comes from a template parameter, give the parameter a default or validate it is non-empty before submit.","If you don't need single-branch behavior, remove `singleBranch: true` so the default branch is cloned."],"exampleFix":"# before\nartifacts:\n- git:\n    repo: https://github.com/org/repo.git\n    singleBranch: true\n# after\nartifacts:\n- git:\n    repo: https://github.com/org/repo.git\n    singleBranch: true\n    branch: main","handlingStrategy":"validation","validationCode":"wf, _ := wfv1.NewWorkflow(...)\nfor _, a := range wf.Spec.Templates {\n    if a.Git != nil && a.Git.SingleBranch && a.Git.Branch == \"\" {\n        return fmt.Errorf(\"git artifact in template %q sets singleBranch without branch\", a.Name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair singleBranch: true with an explicit branch in artifact templates","Give branch template parameters non-empty defaults","Lint workflows (argo lint) before submit — validation catches empty required fields"],"tags":["git","config","argo-workflows"],"backgroundTag":"git-single-branch-missing-branch","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}