Skip to content

#[serde(untagged)] no longer works correctly in serde versions 1.0.220 and above #2981

@rxdiscovery

Description

@rxdiscovery

Hello,

Since I upgraded the serde crate from version 1.0.219 to 1.0.224, the #[serde(untagged)] attribute no longer works.

When I try to deserialize this:

#[derive(Debug, Deserialize, Serialize, Clone, Encode, Decode)]
#[serde(untagged)]
pub enum ConditionValueTypeConfig {
    Single(ConditionValueConfig),
    Multiple(Vec<ConditionValueConfig>),
}

#[derive(Debug, Deserialize, Serialize, Clone, Encode, Decode)]
pub enum ConditionValueConfig {
    String(String),
    Integer(i64),
    Decimal(f64),
    HttpMethod(HttpMethodConfig),
    HttpContentType(ContentTypeConfig),
    HttpStatus(u32),
}

I want to deserialize a RON text like this:

Condition(Method,Eq,HttpMethod(Any))

With serde version 1.0.219 :
OK

With serde version 1.0.220 :
'./conf.ron': 95:99-95:100: data did not match any variant of untagged enum ConditionValueTypeConfig")

With serde version 1.0.224 :
./conf.ron': 95:99-95:100: data did not match any variant of untagged enum ConditionValueTypeConfig")

So the bug has appeared since version 1.0.220

Now have to pin the old version in Cargo.toml.

serde = { version = "=1.0.219", features = ["derive"] }

Thank you in advance for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions