DioxusLabs/dioxus · error

Cannot serialize attribute value

Error message

Cannot serialize attribute value

What it means

While converting attribute values for serializable Mutations, an attribute value type that cannot be serialized (such as an Any or external listener marker) was encountered. This guard indicates a non-serializable AttributeValue reached a serialization path that only supports text, bool, float, and similar plain values.

Source

Thrown at packages/core/src/mutations.rs:434

    /// Remove the top stack node from the renderer tree.
    Remove,
}

/// A static list of mutations that can be applied to the DOM. Note: this list does not contain any `Any` attribute values
#[derive(Debug, PartialEq, Default)]
pub struct Mutations {
    /// Any mutations required to patch the renderer to match the layout of the VirtualDom
    pub edits: Vec<Mutation>,
}

fn serializable_attribute_value(value: &AttributeValue) -> AttributeValue {
    match value {
        AttributeValue::Text(_)
        | AttributeValue::Bool(_)
        | AttributeValue::Float(_)
        | AttributeValue::Int(_)
        | AttributeValue::None => value.clone(),
        _ => panic!("Cannot serialize attribute value"),
    }
}

macro_rules! collect_field_mutations {
    ($($method:ident($field:ident: $field_ty:ty) => $variant:ident;)*) => {
        $(
            fn $method(&mut self, $field: $field_ty) {
                self.edits.push(Mutation::$variant { $field })
            }
        )*
    };
}

macro_rules! collect_string_mutations {
    ($($method:ident($field:ident) => $variant:ident;)*) => {
        $(
            fn $method(&mut self, $field: &str) {
                self.edits.push(Mutation::$variant {

View on GitHub (pinned to 24f6a829df)

Solutions

  1. Use an attribute value type that can be serialized (string, number, bool, or serializable types). Convert custom values to strings before setting the attribute.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/core/src/mutations.rs:434 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/cb693e2d752e47c3. Report an issue: GitHub.