gitbutlerapp/gitbutler · error

Refusing to remove label with degenerate name

Error message

Refusing to remove label with degenerate name {label:?}

What it means

A defensive guard in the label-removal REST call: labels named "", ".", or ".." would produce a malformed or dangerous URL path segment (empty segment or parent-directory traversal), so the client refuses to build the request rather than send a bogus DELETE to GitHub.

Solutions

  1. Fix the caller to never produce empty/"."/".." label names — validate or filter labels before calling.
  2. If the label legitimately looks like this, the data is corrupt; re-fetch the label list from GitHub and use exact names from that response.
  3. Trim whitespace and skip blank entries when collecting label names from user or file input.

Example fix

// before
client.remove_label(owner, repo, pr_number, &label).await?;

// after
anyhow::ensure!(!label.trim().is_empty(), "label name is empty");
client.remove_label(owner, repo, pr_number, label.trim()).await?;
Defensive patterns

Strategy: validation

Validate before calling

fn is_valid_label(name: &str) -> bool {
    !matches!(name.trim(), "" | "." | "..") && !name.trim().is_empty()
}
anyhow::ensure!(is_valid_label(&label), "invalid label name: {label:?}");

Prevention

When it happens

Trigger: Calling remove_label (the `DELETE /repos/{owner}/{repo}/issues/{pr}/labels/...` endpoint wrapper) with a label string that is empty, ".", or ".." — usually from uninitialized data or a parsing bug upstream.

Common situations: A bug producing empty label names when parsing PR labels; accidental use of a placeholder value; a path-traversal-shaped input from untrusted data being passed straight through.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at crates/but-github/src/client.rs:2278

#[derive(Serialize)]
struct ReviewersBody<'a> {
    reviewers: &'a [String],
}

/// Build `DELETE /repos/{o}/{r}/issues/{n}/labels/{name}` with the label name
/// percent-encoded. `PathSegmentsMut::push` silently *drops* `.` and `..`
/// segments, which would degrade this into GitHub's remove-ALL-labels
/// endpoint — refuse those names instead of encoding them.
fn label_removal_url(
    base_url: &str,
    owner: &str,
    repo: &str,
    pr_number: i64,
    label: &str,
) -> Result<reqwest::Url> {
    if matches!(label, "" | "." | "..") {
        bail!("Refusing to remove label with degenerate name {label:?}");
    }

    let mut url = reqwest::Url::parse(&format!(
        "{base_url}/repos/{owner}/{repo}/issues/{pr_number}/labels"
    ))?;
    url.path_segments_mut()
        .map_err(|()| anyhow::anyhow!("Invalid GitHub base URL"))?
        .push(label);
    Ok(url)
}

/// A submitted review on a pull request, with the reactions left on it.
#[derive(Debug, Serialize)]
pub struct PullRequestReview {
    pub id: i64,
    pub author: Option<GitHubUser>,
    /// GitHub state string: `APPROVED`, `CHANGES_REQUESTED`, `COMMENTED`,
    /// `DISMISSED`, or `PENDING` (the caller's own unsubmitted draft).

View on GitHub (pinned to 58e5313667)