juspay/hyperswitch · error · syn::Error

Unexpected {keyword}, possible values are {}

Error message

Unexpected {keyword}, possible values are {}

What it means

Error "Unexpected {keyword}, possible values are {}" thrown in juspay/hyperswitch.

Source

Thrown at crates/router_derive/src/macros/operation.rs:371

                    "Unexpected value for operation: `{value}`. Possible values are `{}`",
                    helpers::get_possible_values_for_enum::<Self>()
                ),
            )
        })
    }
}

fn parse_list_string<T>(list_string: String, keyword: &str) -> syn::Result<Vec<T>>
where
    T: FromStr + IntoEnumIterator + ToString,
{
    list_string
        .split(',')
        .map(str::trim)
        .map(T::from_str)
        .map(|result| {
            result.map_err(|_| {
                syn::Error::new(
                    Span::call_site(),
                    format!(
                        "Unexpected {keyword}, possible values are {}",
                        helpers::get_possible_values_for_enum::<T>()
                    ),
                )
            })
        })
        .collect()
}

fn get_conversions(input: syn::parse::ParseStream<'_>) -> syn::Result<Vec<Conversion>> {
    let lit_str_list = input.parse::<syn::LitStr>()?;
    parse_list_string(lit_str_list.value(), "operation")
}

fn get_derives(input: syn::parse::ParseStream<'_>) -> syn::Result<Vec<Derives>> {
    let lit_str_list = input.parse::<syn::LitStr>()?;

View on GitHub (pinned to 705a321950)

Solutions

  1. Replace the unexpected keyword with one of the listed possible values in the macro invocation

When it happens

Trigger: Thrown at crates/router_derive/src/macros/operation.rs:371 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of juspay/hyperswitch@705a321950 (2026-08-19). Data as JSON: /api/errors/7e8cd8919967fbbc. Report an issue: GitHub.