gitbutlerapp/gitbutler · error

Unknown reaction kind

Error message

Unknown reaction kind: {kind}

What it means

`graphql_reaction_content` maps a REST reaction kind string (e.g. `"+1"`, `"heart"`) to GitHub's GraphQL `ReactionContent` enum name by lookup in `REACTION_CONTENTS`; an unknown string fails with this error. It is a strict input-validation failure: the reaction kind is not one the library knows how to translate.

Solutions

  1. Use one of the supported REST kinds from `REACTION_CONTENTS`: `+1`, `-1`, `laugh`, `confused`, `heart`, `hooray`, `rocket`, `eyes`.
  2. Validate/normalize reaction input against the supported list before calling the API.
  3. Upgrade the library if GitHub introduced a new reaction type; add the mapping if you maintain the code.
  4. Map external reaction names to the GitHub kinds explicitly at the boundary of your integration.

Example fix

// before
client.add_reaction(pr_number, "thumbsup").await?; // unknown kind

// after
client.add_reaction(pr_number, "+1").await?; // valid REACTION_CONTENTS kind
Defensive patterns

Strategy: validation

Validate before calling

const KINDS: &[&str] = &["+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", "eyes"];
fn valid_reaction(kind: &str) -> bool { KINDS.contains(&kind) }

Try / catch

match client.add_reaction(pr_number, kind).await {
    Err(e) if e.to_string().contains("Unknown reaction kind") => {
        eprintln!("Supported kinds: +1, -1, laugh, confused, heart, hooray, rocket, eyes");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Passing a reaction kind string to a reaction-adding client method that is not in `REACTION_CONTENTS` (typo, wrong casing, newer GitHub reaction type the library predates, or arbitrary user input).

Common situations: Hardcoding a reaction kind with a typo (e.g. `"thumbsup"` instead of `"+1"`); syncing reactions from another forge with different names; GitHub adding a new reaction emoji not yet mapped in the library.

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/94f10c8041dc8c28. Report an issue: GitHub.

Appendix: source

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

/// GraphQL's `ReactionContent` enum against the REST kind strings the rest
/// of the crate speaks, so both APIs report one vocabulary.
const REACTION_CONTENTS: [(&str, &str); 8] = [
    ("THUMBS_UP", "+1"),
    ("THUMBS_DOWN", "-1"),
    ("LAUGH", "laugh"),
    ("HOORAY", "hooray"),
    ("CONFUSED", "confused"),
    ("HEART", "heart"),
    ("ROCKET", "rocket"),
    ("EYES", "eyes"),
];

fn graphql_reaction_content(kind: &str) -> Result<&'static str> {
    REACTION_CONTENTS
        .iter()
        .find(|(_, rest)| *rest == kind)
        .map(|(graphql, _)| *graphql)
        .ok_or_else(|| anyhow::anyhow!("Unknown reaction kind: {kind}"))
}

fn rest_reaction_kind(content: String) -> String {
    REACTION_CONTENTS
        .iter()
        .find(|(graphql, _)| *graphql == content)
        .map_or(content, |(_, rest)| (*rest).to_owned())
}

impl GraphQlReaction {
    /// `None` without a database id, which is what callers hold; a made-up 0 would collide.
    fn into_reaction(self) -> Option<Reaction> {
        let Some(id) = self.database_id else {
            tracing::warn!("a reaction without a database id was skipped");
            return None;
        };
        Some(Reaction {
            id,

View on GitHub (pinned to 58e5313667)