cbor icon indicating copy to clipboard operation
cbor copied to clipboard

Deserialization of enum variants only accepts fixed length map

Open valpackett opened this issue 4 years ago • 1 comments

https://github.com/pyfisch/cbor/blob/a218403a52e60c991313f429e4acc05cce81ce25/src/de.rs#L859

If I try to write an enum as e.g. \xbf\x67variant\x65hello\xff there's a somewhat confusing error: "invalid type: map, expected variant identifier"

This is probably not common (I was just writing a test with manually written cbor bytes) but theoretically some implementation in another language could always rewrite maps into indeterminate length maps..

valpackett avatar Jul 05 '20 16:07 valpackett

I ran into this with CBOR generated from JSON in Java's Jackson. [Edit:] It also happens with @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT), which is roughly equivalent to serde's external tagging.

jcfj avatar Jun 28 '21 01:06 jcfj