{"record":{"id":"44b9049776cf322a","repo":"gitbutlerapp/gitbutler","slug":"hashtag-cannot-be-empty","errorCode":null,"errorMessage":"Hashtag cannot be empty","messagePattern":"Hashtag cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/push.rs","lineNumber":1067,"sourceCode":"\n    if !gerrit_mode {\n        return Ok(vec![]);\n    }\n\n    let mut flags = Vec::new();\n\n    // Handle Wip/Ready - Ready is default if neither is specified\n    if args.wip {\n        flags.push(but_gerrit::PushFlag::Wip);\n    } else {\n        // Default to Ready, or explicit Ready\n        flags.push(but_gerrit::PushFlag::Ready);\n    }\n\n    // Handle hashtags - can be multiple\n    for hashtag in &args.hashtag {\n        if hashtag.trim().is_empty() {\n            return Err(anyhow::anyhow!(\"Hashtag cannot be empty\"));\n        }\n        flags.push(but_gerrit::PushFlag::Hashtag(hashtag.clone()));\n    }\n\n    // Handle topic - at most one\n    if let Some(topic) = &args.topic {\n        if topic.trim().is_empty() {\n            return Err(anyhow::anyhow!(\"Topic cannot be empty\"));\n        }\n        flags.push(but_gerrit::PushFlag::Topic(topic.clone()));\n    } else if args.topic_from_branch {\n        flags.push(but_gerrit::PushFlag::Topic(branch_name.to_string()));\n    }\n\n    // Handle private flag\n    if args.private {\n        flags.push(but_gerrit::PushFlag::Private);\n    }","sourceCodeStart":1049,"sourceCodeEnd":1085,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/push.rs#L1049-L1085","documentation":"get_gerrit_flags throws this when a --hashtag value passed to a Gerrit push consists only of whitespace. An empty hashtag is meaningless to Gerrit and would produce a malformed push flag, so it is rejected before any push is attempted.","triggerScenarios":"Running `but push --hashtag \"\"` or `--hashtag \"   \"`, or passing a quoted-but-empty variable from a shell script into the hashtag flag.","commonSituations":"Shell variables that expand to empty strings (`--hashtag \"$TAG\"` with unset TAG), accidental double-space arguments, or template-generated commands with blank placeholders.","solutions":["Pass a non-empty hashtag value: `but push --hashtag review-blocking`","Check the sourcing script for unset/empty variables feeding the flag","Omit the --hashtag flag entirely if no hashtag is needed"],"exampleFix":"// before\nbut push --hashtag \"\"   // error: Hashtag cannot be empty\n// after\nbut push --hashtag my-hashtag","handlingStrategy":"validation","validationCode":"// validate hashtag values before invoking push\nconst tags = hashtags.filter(t => t && t.trim().length > 0);\nif (tags.length !== hashtags.length) {\n  throw new Error('Hashtag values must be non-empty');\n}","typeGuard":"function isValidHashtag(t: string): boolean {\n  return typeof t === 'string' && t.trim().length > 0;\n}","tryCatchPattern":"try {\n  await runBut(['push', ...flags]);\n} catch (e) {\n  if (/Hashtag cannot be empty/.test(e.message)) {\n    console.error('Provide a non-empty --hashtag value');\n    return;\n  }\n  throw e;\n}","preventionTips":["Guard shell variables feeding --hashtag against unset values","Trim and filter hashtag arrays before building CLI args","Omit --hashtag entirely when no hashtag is needed"],"tags":["cli","push","gerrit","validation","hashtags"],"backgroundTag":"empty-required-field","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"}