Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

[Bug] Failed to deserialize a enum inside a tagged enum. #378

Open
peng1999 opened this issue Jun 24, 2023 · 0 comments
Open

[Bug] Failed to deserialize a enum inside a tagged enum. #378

peng1999 opened this issue Jun 24, 2023 · 0 comments

Comments

@peng1999
Copy link

use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize)]
#[serde(tag = "version")]
enum Outer {
    V1(OuterContent),
}

#[derive(Serialize, Deserialize)]
struct OuterContent {
    a: Inner,
}

#[derive(Serialize, Deserialize)]
enum Inner {
    M {},
}

fn main() {
    let obj = Outer::V1(OuterContent { a: Inner::M {} });

    let b = serde_yaml::to_string(&obj).unwrap();
    println!("{}", b);

    let obj = serde_yaml::from_str::<Outer>(&b).unwrap();
}

The above code failed with output:

version: V1
a: !M {}

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("a: untagged and internally tagged enums do not support enum input", line: 2, column: 4)', src/main.rs:25:49

This bug is introduced in version 0.9. Maybe it has something to do with !tag syntax.
Related: #344

danieldk added a commit to tensordot/syntaxdot that referenced this issue Oct 15, 2023
danieldk added a commit to tensordot/syntaxdot that referenced this issue Oct 15, 2023
bors bot pushed a commit to infinyon/fluvio that referenced this issue Nov 2, 2023
Added cascade deletion for local metadata.

Also, fixed a bug with deserialization failure for nested enums if the outer enum is tagged. More details here dtolnay/serde-yaml#378. Fixed by removing external tagging for versioned spec and added unit-tests that cover this case.

Also fixes #3632
bors bot pushed a commit to infinyon/fluvio that referenced this issue Nov 2, 2023
Added cascade deletion for local metadata.

Also, fixed a bug with deserialization failure for nested enums if the outer enum is tagged. More details here dtolnay/serde-yaml#378. Fixed by removing external tagging for versioned spec and added unit-tests that cover this case.

Also fixes #3632
bors bot pushed a commit to infinyon/fluvio that referenced this issue Nov 3, 2023
Added cascade deletion for local metadata.

Also, fixed a bug with deserialization failure for nested enums if the outer enum is tagged. More details here dtolnay/serde-yaml#378. Fixed by removing external tagging for versioned spec and added unit-tests that cover this case.

Also fixes #3632
vrrashkov pushed a commit to vrrashkov/fluvio that referenced this issue Nov 3, 2023
Added cascade deletion for local metadata.

Also, fixed a bug with deserialization failure for nested enums if the outer enum is tagged. More details here dtolnay/serde-yaml#378. Fixed by removing external tagging for versioned spec and added unit-tests that cover this case.

Also fixes infinyon#3632
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant