-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deps: bump quick-xml dependency from 0.30 to 0.31 #21
Conversation
There are two kinds of failures, these are examples:
|
That is not the reason of the mentioned errors, but you at least has one error in your Lines 235 to 236 in e991bdf
Replace that arm with #[cfg(feature = "nil")]
Field::Nil => {
let _: IgnoredAny = map.next_value()?;
Ok(Value::nil())
} |
Note, that Lines 112 to 113 in 65f629b
In serde model you cannot rename field of a tuple or a newtype (tuple with 1 element). All variants of Type are newtypes in serde model. Actually, that is serde bug that it do not report error about not applicable attribute here.
In terms of quick-xml |
This error because you also does not implement Lines 190 to 191 in 65f629b
I will use test with shorter XML for explanation: dxr/dxr/src/tests/xml/structs.rs Lines 12 to 18 in 65f629b
When // <value><i4>42</i4></value></member>
let value: Value = MapValueDeserializer::deserialize_any(ValueVisitor);
// ....actually, because the first event at start is not Text
let value: Value = MapValueDeserializer::deserialize_map(ValueVisitor);
// ...actually, because deserialize_map implemented via deserialize_struct
let value: Value = MapValueDeserializer::deserialize_struct("", &[] ValueVisitor);
// ...actually, MapValueDeserializer::deserialize_struct delegates to Deserializer::deserialize_struct
let value: Value = Deserializer::deserialize_struct("", &[] ValueVisitor);
// consumes <value>
let value: Value = ValueVisitor.visit_map(ElementMapAccess)
// key
// <i4>42</i4></value></member>
let field: Field = ElementMapAccess::next_key()
let field: Field = ElementMapAccess::next_key_seed(PhantomData)
let field: Field = PhantomData::deserialize(QNameDeserializer("i4"))
let field: Field = Field::deserialize(QNameDeserializer("i4"))
let field: Field = QNameDeserializer("i4").deserialize_identifier(FieldVisitor)
let field: Field = FieldVisitor.visit_str("i4"); // returns Field::i4
// value
// <i4>42</i4></value></member>
let value: i32 = ElementMapAccess::next_value()
let value: i32 = ElementMapAccess::next_value_seed(PhantomData)
let value: i32 = PhantomData::deserialize(MapValueDeserializer)
let value: i32 = i32::deserialize(MapValueDeserializer)
let value: i32 = MapValueDeserializer::deserialize_i32(PrimitiveVisitor)
let s: String = MapValueDeserializer::read_string()
// Consumes <i4>
let s: String = Deserializer::read_string_impl(true)
// 42</i4></value></member>
// Consumes 42</i4>
let s: String = Deserializer::read_text()
// </value></member>
let value: i32 = PrimitiveVisitor::visit_i32("42".parse()?); // Returns 42
// Because you read only one key, </value> is not consumed Here
dxr types:
serde types:
So because of bug in your implementation, Both errors are not quick-xml specific, you will get the same results with JSON, for example. |
Error
due to the same reason, it's just the execution path is different, so you get a different error. |
Oof 😬 thank you for the detailed response! I suspected that our custom deserialization logic was to blame. |
e991bdf
to
f4c7e62
Compare
Looks like applying your fixes made all the difference. All the tests pass now. Thank you so much! 🚀 |
return Ok(Value::string(String::new())); | ||
}; | ||
|
||
if let Some(key) = map.next_key::<Field>()? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably changing Field
to have Unknown(Cow<str>)
variant will be better to handle error more gracefully here. Then the error could be more clear that you have unexpected key even if that is not a key that Field
can recognize. Currently for the field abcdef
you will get "unknown field" error instead of "Unexpected key" error, but I think, that this key in the first place is unexpected and only after that is unknown.
With that variant emit unknown field error in match
at line 191.
Also, it maybe worth to add some formal tests for the deserializer implementation using serde_test
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into this, thank you!
This compiles but fails tests. There are assertion failures internal to quick-xml code that I don't understand (see CI output once it runs).
Maybe @Mingun has an idea what's going on? I suppose our custom Deserializer for
Value
is the cause, but I can't tell why:https://github.com/ironthree/dxr/blob/quick-xml-0.31/dxr/src/values/ser_de.rs#L94