tinyhumansai/openhuman · error

Invalid branch specification

Error message

Invalid branch specification

What it means

After sanitization, the branch parameter did not reduce to exactly one clean token — it is either empty or split into multiple whitespace-separated pieces — so it cannot be used as a single branch name for checkout.

Source

Thrown at src/openhuman/tools/impl/filesystem/git_operations.rs:374

            Err(e) => Ok(ToolResult::error(format!("Add failed: {e}"))),
        }
    }

    async fn git_checkout(
        &self,
        cwd: &Path,
        args: serde_json::Value,
    ) -> anyhow::Result<ToolResult> {
        let branch = args
            .get("branch")
            .and_then(|v| v.as_str())
            .ok_or_else(|| anyhow::anyhow!("Missing 'branch' parameter"))?;

        // Sanitize branch name
        let sanitized = self.sanitize_git_args(branch)?;

        if sanitized.is_empty() || sanitized.len() > 1 {
            anyhow::bail!("Invalid branch specification");
        }

        let branch_name = &sanitized[0];

        // Block dangerous branch names
        if branch_name.contains('@') || branch_name.contains('^') || branch_name.contains('~') {
            anyhow::bail!("Branch name contains invalid characters");
        }

        let output = self
            .run_git_command_in(cwd, &["checkout", branch_name])
            .await;

        match output {
            Ok(_) => Ok(ToolResult::success(format!(
                "Switched to branch: {branch_name}"
            ))),
            Err(e) => Ok(ToolResult::error(format!("Checkout failed: {e}"))),

View on GitHub (pinned to 7491200858)

Solutions

  1. Pass a single branch name with no spaces, e.g. 'feature/x'
  2. Quote the value correctly in the JSON arguments so it arrives as one string
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/openhuman/tools/impl/filesystem/git_operations.rs:374 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/2c015f7c9af0fdb8. Report an issue: GitHub.