gitbutlerapp/gitbutler · error

unknown publish target '{other}'. Use `but agentlog publish

Error message

unknown publish target '{other}'. Use `but agentlog publish <branch>` or `but agentlog publish <branch|review|change> <value>`.

What it means

but agentlog publish takes either a bare branch name or a target-kind keyword plus value. resolve_publish_target inspects the first argument only when a second value is present and accepts just 'branch', 'review', and 'change'; anything else in the keyword slot produces this bail listing the accepted forms.

Source

Thrown at crates/but-agentlog/src/cli.rs:461

            Ok(CommandOutput::Message {
                message: "Synced GitMeta metadata".into(),
            })
        }
    }
}

fn resolve_publish_target(
    branch_or_target: String,
    value: Option<String>,
) -> anyhow::Result<(RelatedSessionTarget, String)> {
    let Some(value) = value else {
        return Ok((RelatedSessionTarget::Branch, branch_or_target));
    };
    match branch_or_target.as_str() {
        "branch" => Ok((RelatedSessionTarget::Branch, value)),
        "review" => Ok((RelatedSessionTarget::Review, value)),
        "change" => Ok((RelatedSessionTarget::Change, value)),
        other => anyhow::bail!(
            "unknown publish target '{other}'. Use `but agentlog publish <branch>` or `but agentlog publish <branch|review|change> <value>`."
        ),
    }
}

fn run_hook(dir: &Path, agent: Option<Agent>, input: &str) -> anyhow::Result<Option<PathBuf>> {
    let input: HookInput =
        serde_json::from_str(input).context("failed to parse agent hook input")?;
    let Some(transcript_path) = input
        .transcript_path
        .filter(|path| !path.as_os_str().is_empty())
    else {
        return Ok(None);
    };
    let dir = input
        .cwd
        .as_deref()
        .filter(|path| !path.as_os_str().is_empty())

View on GitHub (pinned to 2497b8007a)

Solutions

  1. Use a documented keyword: but agentlog publish branch <name>, but agentlog publish review <id>, or but agentlog publish change <id>.
  2. To publish for the current branch, pass only the branch name: but agentlog publish <branch>.
  3. Check `but agentlog publish --help` for the accepted forms before scripting.

Example fix

# before
but agentlog publish pr 4521
# after
but agentlog publish review 4521
Defensive patterns

Strategy: validation

Validate before calling

const PUBLISH_KINDS: &[&str] = &["branch", "review", "change"];

fn valid_publish_invocation(first: &str, value: Option<&str>) -> bool {
    match value {
        None => true, // bare branch form
        Some(_) => PUBLISH_KINDS.contains(&first),
    }
}

Prevention

When it happens

Trigger: Running `but agentlog publish <x> <y>` where <x> is not branch/review/change — e.g. `but agentlog publish pr 123`, a flag like --target in the keyword position, or a branch name accidentally followed by another value.

Common situations: Assuming a 'pr'/'pull-request' keyword exists; passing flag-style options where positional keywords are expected; copy-paste from older docs.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@2497b8007a (2026-08-17). Data as JSON: /api/errors/03af9cd8c7766fc9. Report an issue: GitHub.