RReverser / serde-xml-rs

xml-rs based deserializer for Serde (compatible with 1.0+)
https://crates.io/crates/serde-xml-rs
MIT License
269 stars 90 forks source link

bugfix for is_map_value stays true after vec of struct in enum #204

Open mike-kfed opened 1 year ago

mike-kfed commented 1 year ago

I ran into this head-scratcher today, history:

  1. upgraded software that used serde-xml-rs v0.3.0 to use v0.6.0.
  2. It compiled fine but parsing broke.
  3. found out that parsing still works on 0.4.1
  4. investigated what happens and built a minimal test case
  5. the self.is_map_value is true after parsing the <enumerationDefinition> which when continuing, inside read_inner_value (), skips the StartElement of the next xml item (<messageDefinition>) and then is confused because the enum Definition has no variant for <field> items.
  6. changing the order of the XML elements actually makes it parseable again 🤔

point 6. made me believe this is a bug and self.is_map_value should be reset when a new StartElement is coming up for an enum - since I don't fully grok the description what this struct field really does for read_inner_value(), please double verify this is all good. All tests succeed, so I guess my fix is fine and has no side-effects?

I'll adapt this patch however needed, I do realise this is more of a bug report including a potential fix than a PR. I'd like to advocate though to keep the test case of this PR at least please :)