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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaking change to deserialization in 0.27.0 - Err value: Custom("missing field
...")
#558
Comments
I hope this helps you, random future github user, if you find this issue while searching for the meaning a Hey maintainers, thanks for your work on this module!! |
I am excited that this new nomenclature will let me describe which struct fields should be serialized as attributes vs elements. I did enjoy the robust flexibility of parsing either form with the same struct code. XML that doesn't have an associated DTD can easily get munged between attr and elems during read-edit-export processes. |
Well, the changelog mentions this change, but maybe not highlights it very well as it should. In any case, I glad that you found the root cause and shared your experience :) |
馃憤 |
You should name your attributes starting with |
Unexpected breaking change to deserialization behavior. (AKA a bug was fixed 馃槃 )
Updating to current v0.27.1 caused my deserializer library to fail with a
Custom("missing field '...')
.Note: the error message uses backticks (`) rather than single quotes ('), but those are hard to write in markdown. This error did not make it clear how to find the problem. Updating from v0.23.0 to v0.26.0 was transparent. Updating to v0.27.1 caused errors.
After a considerable amount of digging, I found that this was an intentional change. I don't know where I should have looked to find information about the change and how to migrate my code. The documentation for quick_xml::de was updated with the new syntax, but it doesn't show that the syntax changed in this version.
The change:
Deserialization used to treat attributes and elements equivalently when de-serializing. This was changed in v0.27.0, as part of the serializer rewrite in #490 . Specifically commit 8b50c64
The description of #490 contains this "Notable Change" notice
Prior to 0.27, these two documents could both be deserialized into the same struct definition:
With the change to v0.27 those two documents are distinct and deserialize into different structures. Attributes now have a
@
prefix and will need to a serde(rename) to convert to a valid type name. The two example documents now require slightly different struct definitions:The text was updated successfully, but these errors were encountered: