{"record":{"id":"e7ee1bd0c623c3cc","repo":"gitbutlerapp/gitbutler","slug":"topic-cannot-be-empty","errorCode":null,"errorMessage":"Topic cannot be empty","messagePattern":"Topic cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/push.rs","lineNumber":1075,"sourceCode":"    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    }\n\n    Ok(flags)\n}\n\nfn resolve_branch_name(\n    ctx: &mut Context,\n    id_map: &IdMap,\n    branch_id: &str,","sourceCodeStart":1057,"sourceCodeEnd":1093,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/push.rs#L1057-L1093","documentation":"The `but push` Gerrit integration rejects a topic flag that is empty or only whitespace. A Gerrit change topic must be a non-empty string, so pushing with one would produce an invalid Gerrit push spec; the library fails fast before constructing push flags.","triggerScenarios":"Running `but push --topic \"\"` (or `--topic \"   \"`) against a Gerrit remote, where args.topic is Some but trims to empty in get_gerrit_flags.","commonSituations":"Shell variables that expand to empty (e.g. `--topic \"$MY_TOPIC\"` with MY_TOPIC unset), scripting the CLI where a field is blank in CI, copy-pasting a command with a missing topic value.","solutions":["Pass a non-empty topic: `but push --topic my-topic`.","Omit `--topic` entirely and let `--topic-from-branch` derive it from the branch name.","Trim/default the value in your script before invoking the CLI, e.g. `TOPIC=\"${MY_TOPIC:?topic required}\"`.","If deriving programmatically, fall back to the branch name when the topic is blank."],"exampleFix":"// before\nbut push --topic \"$TOPIC\"\n// after\nbut push --topic \"${TOPIC:-$(git branch --show-current)}\"","handlingStrategy":"validation","validationCode":"if [ -z \"$(echo \"$TOPIC\" | tr -d '[:space:]')\" ]; then echo \"--topic must be non-empty\"; exit 1; fi\nbut push --topic \"$TOPIC\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never interpolate possibly-empty shell variables into --topic without a default","Prefer --topic-from-branch when the branch name is a suitable topic","Validate topic is non-empty after trimming before invoking the CLI"],"tags":["cli","gerrit","validation"],"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"}