{"record":{"id":"3dabc66aea132c72","repo":"gitbutlerapp/gitbutler","slug":"refusing-to-operation-symbolic-ref-due-to-p","errorCode":null,"errorMessage":"Refusing to {operation} symbolic ref '{}' due to potential ambiguity","messagePattern":"Refusing to (.+?) symbolic ref '(.+?)' due to potential ambiguity","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/branch/mod.rs","lineNumber":540,"sourceCode":"}\n\n/// Find `branch` in `repo` and reject it if it resolves to a symbolic reference.\n///\n/// `operation` is used only for the error message so callers such as apply and unapply can share\n/// validation while still reporting the action they refused to perform.\n///\n/// Missing references are returned as `Ok(None)` so each caller can decide whether absence is an error or a no-op.\npub(crate) fn try_find_validated_ref<'repo>(\n    repo: &'repo gix::Repository,\n    branch: &gix::refs::FullNameRef,\n    operation: &str,\n) -> anyhow::Result<Option<gix::Reference<'repo>>> {\n    let branch_ref = repo.try_find_reference(branch)?;\n    if branch_ref\n        .as_ref()\n        .is_some_and(|r| matches!(r.target(), gix::refs::TargetRef::Symbolic(_)))\n    {\n        anyhow::bail!(\n            \"Refusing to {operation} symbolic ref '{}' due to potential ambiguity\",\n            branch.shorten()\n        );\n    }\n    Ok(branch_ref)\n}\n\n/// Setup `local_tracking_ref` to track `remote_tracking_ref`, and prepare a locked configuration\n/// transaction with the branch configuration added.\n/// We also return the commit at which `local_tracking_ref` should be placed, which is assumed to not exist.\npub(crate) fn setup_local_tracking_configuration(\n    repo: &gix::Repository,\n    local_tracking_ref: &gix::refs::FullNameRef,\n    remote_tracking_ref: &gix::refs::FullNameRef,\n) -> anyhow::Result<(gix::config::FileTransaction, gix::ObjectId)> {\n    let remote_tracking_commit_id = repo\n        .find_reference(remote_tracking_ref)?\n        .peel_to_commit()?","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/branch/mod.rs#L522-L558","documentation":"try_find_validated_ref refuses to operate on a reference that is symbolic (points at another ref rather than an OID), because operations like apply/unapply would then affect the pointed-to branch rather than the named one, creating ambiguity. The caller's operation name is interpolated into the message.","triggerScenarios":"Calling apply, local_tracking_branch, or unapply with a branch name that resolves in the repository to a symbolic ref (e.g. a local HEAD alias or origin/HEAD-style ref).","commonSituations":"Passing `origin/HEAD` or a workspace alias ref as the branch argument; configs where the workspace branch name collides with a symbolic ref created by clone or tooling.","solutions":["Pass the concrete branch name (the ref that directly holds a commit target), not a symbolic alias such as HEAD or origin/HEAD","Delete or rename the symbolic ref if it shadows a real branch name you intend to operate on","Resolve the symbolic ref to its target first and call the API with the resolved name"],"exampleFix":"// before\napply(repo, \"origin/HEAD\")?;\n// after\nlet target = repo.find_reference(\"origin/HEAD\")?.follow().unwrap().1;\napply(repo, target.name().shorten().as_str())?;","handlingStrategy":"validation","validationCode":"fn is_symbolic(repo: &gix::Repository, branch: &str) -> anyhow::Result<bool> {\n    Ok(repo.try_find_reference(branch)?\n        .map(|r| matches!(r.target(), gix::refs::TargetRef::Symbolic(_)))\n        .unwrap_or(false))\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"symbolic ref\") => {\n        anyhow::bail!(\"pass a concrete branch, not a symbolic ref: {e}\");\n    }\n    other => other,\n}","preventionTips":["Never pass HEAD or origin/HEAD-style aliases as branch arguments","Resolve symbolic refs to their target before calling apply/unapply","Audit configs for symbolic refs that shadow real branch names"],"tags":["git","refs","symbolic-ref"],"backgroundTag":"unsupported-operation","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}