gitbutlerapp/gitbutler · error
Hashtag cannot be empty
Error message
Hashtag cannot be empty
What it means
With gerrit mode enabled, each `--hashtag` value is trimmed and must be non-empty before it becomes `but_gerrit::PushFlag::Hashtag`. Empty or whitespace-only input is rejected because a Gerrit hashtag is review metadata and cannot be blank.
Source
Thrown at crates/but/src/command/legacy/push.rs:1075
if !gerrit_mode {
return Ok(vec![]);
}
let mut flags = Vec::new();
// Handle Wip/Ready - Ready is default if neither is specified
if args.wip {
flags.push(but_gerrit::PushFlag::Wip);
} else {
// Default to Ready, or explicit Ready
flags.push(but_gerrit::PushFlag::Ready);
}
// Handle hashtags - can be multiple
for hashtag in &args.hashtag {
if hashtag.trim().is_empty() {
return Err(anyhow::anyhow!("Hashtag cannot be empty"));
}
flags.push(but_gerrit::PushFlag::Hashtag(hashtag.clone()));
}
// Handle topic - at most one
if let Some(topic) = &args.topic {
if topic.trim().is_empty() {
return Err(anyhow::anyhow!("Topic cannot be empty"));
}
flags.push(but_gerrit::PushFlag::Topic(topic.clone()));
} else if args.topic_from_branch {
flags.push(but_gerrit::PushFlag::Topic(branch_name.to_string()));
}
// Handle private flag
if args.private {
flags.push(but_gerrit::PushFlag::Private);
}View on GitHub (pinned to caf1f223d3)
Solutions
- Remove the empty --hashtag argument
- Give the hashtag a real value: `but push --hashtag my-team`
- Guard scripts to skip empty values when building the flag list
Example fix
# before but push --hashtag "" # error: Hashtag cannot be empty # after but push --hashtag my-team
Defensive patterns
Strategy: validation
Validate before calling
# Drop empty/blank hashtags before invoking but
args=()
for tag in "${hashtags[@]}"; do
[ -n "${tag//[[:space:]]/}" ] && args+=(--hashtag "$tag")
done
but push "${args[@]}" Prevention
- Validate list-valued flags in wrappers before exec
- Quote CI variables so empty ones are visible instead of silently forwarded
- Fail fast on blank inputs rather than passing them through
When it happens
Trigger: Running `but push --hashtag ""` or `--hashtag " "` in a Gerrit-enabled repo; a shell loop expanding an empty variable into the flag.
Common situations: CI variable left empty and passed through a loop; copy-paste leaving a placeholder value; accidental empty element in a flag list.
Related errors
- Topic cannot be empty
- Gerrit push flags (--wip, --ready, --hashtag/--tag, --topic,
- Failed to determine Gerrit target branch
- BUG: It should not be possible to omit sources
- {} target value is required
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/44b9049776cf322a.
Report an issue: GitHub.