gitbutlerapp/gitbutler · error
Refusing to symbolic ref ' ' due to potential ambiguity
Error message
Refusing to {operation} symbolic ref '{}' due to potential ambiguity What it means
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.
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
Example fix
// before
apply(repo, "origin/HEAD")?;
// after
let target = repo.find_reference("origin/HEAD")?.follow().unwrap().1;
apply(repo, target.name().shorten().as_str())?; Defensive patterns
Strategy: validation
Validate before calling
fn is_symbolic(repo: &gix::Repository, branch: &str) -> anyhow::Result<bool> {
Ok(repo.try_find_reference(branch)?
.map(|r| matches!(r.target(), gix::refs::TargetRef::Symbolic(_)))
.unwrap_or(false))
} Try / catch
match result {
Err(e) if e.to_string().contains("symbolic ref") => {
anyhow::bail!("pass a concrete branch, not a symbolic ref: {e}");
}
other => other,
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Can only delete local branches under refs/heads, got
- Expected ' ' to be a remote tracking branch, but was
- failed to determine remote for non remote-tracking branch
- GitNonFastForward
- HEAD does not point to a local branch
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/3dabc66aea132c72.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-workspace/src/branch/mod.rs:540
}
/// Find `branch` in `repo` and reject it if it resolves to a symbolic reference.
///
/// `operation` is used only for the error message so callers such as apply and unapply can share
/// validation while still reporting the action they refused to perform.
///
/// Missing references are returned as `Ok(None)` so each caller can decide whether absence is an error or a no-op.
pub(crate) fn try_find_validated_ref<'repo>(
repo: &'repo gix::Repository,
branch: &gix::refs::FullNameRef,
operation: &str,
) -> anyhow::Result<Option<gix::Reference<'repo>>> {
let branch_ref = repo.try_find_reference(branch)?;
if branch_ref
.as_ref()
.is_some_and(|r| matches!(r.target(), gix::refs::TargetRef::Symbolic(_)))
{
anyhow::bail!(
"Refusing to {operation} symbolic ref '{}' due to potential ambiguity",
branch.shorten()
);
}
Ok(branch_ref)
}
/// Setup `local_tracking_ref` to track `remote_tracking_ref`, and prepare a locked configuration
/// transaction with the branch configuration added.
/// We also return the commit at which `local_tracking_ref` should be placed, which is assumed to not exist.
pub(crate) fn setup_local_tracking_configuration(
repo: &gix::Repository,
local_tracking_ref: &gix::refs::FullNameRef,
remote_tracking_ref: &gix::refs::FullNameRef,
) -> anyhow::Result<(gix::config::FileTransaction, gix::ObjectId)> {
let remote_tracking_commit_id = repo
.find_reference(remote_tracking_ref)?
.peel_to_commit()?View on GitHub (pinned to 58e5313667)