gitbutlerapp/gitbutler · error

unknown publish target

Error message

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

What it means

resolve_publish_target in crates/but-agentlog/src/cli.rs validates the target kind for `but agentlog publish`. After the branch-shorthand path, only the literal kinds "branch", "review", or "change" are accepted; anything else bails with the unknown-publish-target message.

Solutions

  1. Use an accepted kind: `but agentlog publish <branch>` or `but agentlog publish branch|review|change <value>`.
  2. Map unsupported kinds (e.g. pr) to the closest supported one before invoking (pr -> review).
  3. Validate the kind in your script against the fixed set {branch, review, change} before calling.

Example fix

// before
but agentlog publish pr 123
// after
but agentlog publish review 123
Defensive patterns

Strategy: validation

Validate before calling

case "$KIND" in
  branch|review|change) ;;
  *) echo "unsupported target kind: $KIND"; exit 1 ;;
esac

Prevention

When it happens

Trigger: Calling resolve_publish_target (via run_from_dir for `but agentlog publish <kind> <value>`) where <kind> is not branch/review/change, e.g. `but agentlog publish pr 123` or a misspelled kind like `brnch`.

Common situations: Misspelling the target kind, assuming other kinds like pr/tag are supported, or scripts parameterizing the kind with an unsupported value.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/03af9cd8c7766fc9. Report an issue: GitHub.

Appendix: 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 58e5313667)