juspay/hyperswitch · error · syn::Error

Please use the macro with attribute #[encrypt] on the fields

Error message

Please use the macro with attribute #[encrypt] on the fields you want to encrypt

What it means

Error "Please use the macro with attribute #[encrypt] on the fields you want to encrypt" thrown in juspay/hyperswitch.

Source

Thrown at crates/router_derive/src/macros/to_encryptable.rs:246

/// This function generates the temporary struct and ToEncryptable impls for the temporary structs
fn generate_to_encryptable(
    struct_name: Ident,
    fields: Vec<Field>,
) -> syn::Result<proc_macro2::TokenStream> {
    let struct_types = [
        // The first two are to be used as return types we do not need to implement ToEncryptable
        // on it
        ("Decrypted", StructType::Decrypted),
        ("DecryptedUpdate", StructType::DecryptedUpdate),
        ("FromRequestEncryptable", StructType::FromRequest),
        ("Encrypted", StructType::Encrypted),
        ("UpdateEncryptable", StructType::Updated),
    ];

    let inner_types = get_field_and_inner_types(&fields);

    let inner_type = inner_types.first().ok_or_else(|| {
        syn::Error::new(
            proc_macro2::Span::call_site(),
            "Please use the macro with attribute #[encrypt] on the fields you want to encrypt",
        )
    })?;

    let provided_ty = get_encryption_ty_meta(&inner_type.0)
        .map(|ty| ty.value.clone())
        .unwrap_or(inner_type.1.clone());

    let structs = struct_types.iter().map(|(prefix, struct_type)| {
        let name = format_ident!("{}{}", prefix, struct_name);
        let temp_fields = struct_type.generate_struct_fields(&inner_types);
        quote! {
            pub struct #name {
                #(#temp_fields,)*
            }
        }
    });

View on GitHub (pinned to 705a321950)

Solutions

  1. Mark the fields to encrypt with the #[encrypt] attribute as instructed

When it happens

Trigger: Thrown at crates/router_derive/src/macros/to_encryptable.rs:246 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/15b09fe1bf717bf2. Report an issue: GitHub.