{"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":1083,"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":1065,"sourceCodeEnd":1101,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/push.rs#L1065-L1101","documentation":"With gerrit mode on, `--topic` is trimmed and must be non-empty before becoming `but_gerrit::PushFlag::Topic`; whitespace-only input is rejected because Gerrit topics group related changes and cannot be blank. If you want the branch name as the topic, `--topic-from-branch` derives it in the same function without needing --topic.","triggerScenarios":"Running `but push --topic \"\"` or `--topic \"   \"` in a Gerrit-enabled repo, typically via an unset variable in a script.","commonSituations":"Empty CI variable forwarded as --topic; placeholder topic never replaced; interactive script bug producing blank input.","solutions":["Give --topic a real value: `but push --topic my-topic`","Or use `but push --topic-from-branch` to derive the topic from the branch name","Remove the flag entirely if no topic is needed"],"exampleFix":"# before\nbut push --topic \"\"\n# error: Topic cannot be empty\n\n# after\nbut push --topic my-topic\n# or\nbut push --topic-from-branch","handlingStrategy":"validation","validationCode":"# Validate the topic before pushing\n[ -n \"${topic//[[:space:]]/}\" ] || { echo 'empty --topic' >&2; exit 1; }\nbut push --topic \"$topic\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check optional flags for blank values before invoking but","Prefer --topic-from-branch when the topic should track the branch name","Set defaults for CI-provided topics so they are never empty"],"tags":["gerrit","push","topic","argument-validation"],"backgroundTag":"empty-string-argument","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}