-
Notifications
You must be signed in to change notification settings - Fork 70
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
can't deserialize nested field with same name + other fields #76
Comments
Hi @scottlamb, Thank you for the issue. That works: #[test]
fn de_same_field_name_but_some_other_fields_or_something() {
#[derive(Default, PartialEq, Debug, YaDeserialize, YaSerialize)]
#[yaserde(rename="foo")]
pub struct FooOuter {
pub other: bool,
#[yaserde(rename="faa")]
pub foo: Option<FooInner>,
}
#[derive(Default, PartialEq, Debug, YaDeserialize, YaSerialize)]
pub struct FooInner {
pub blah: bool,
}
let content = r#"
<foo>
<other>false</other>
<faa>
<blah>false</blah>
</faa>
</foo>
"#;
let model = FooOuter {
other: false,
foo: Some(FooInner {
blah: false,
}),
};
serialize_and_validate!(model, content);
deserialize_and_validate!(content, model, FooOuter);
} Changing |
Thanks for confirming! In |
I've been looking into this issue a bit. First, I wrote something incorrect here:
I was referring to the line below. It's not using But this one seems wrong: What I'd like to do is to (as I mentioned before) not treat the same element name specially. Either it's at the opening depth (and we can call More generally, I'd like to set a more precise contract around
but this is a change in a few ways that I think requires a major version bump. Your thoughts? In particular:
In any case, I'll send a PR to improve debuggability a bit. Initialize logging in each of the tests as described here (with a new |
My preference would be to not support the Anyway, I'll send you some hopefully-uncontroversial cleanup/debugging stuff and await your opinion on contract changes. I'll likely have more contract questions for you later, but this seems like a good first round to address this immediate problem. |
@MarcAntoine-Arnaud is there any reason why using pull parser? Is it for performance reasons? I'm just thinking that code could be much cleaner if using xml-tree 🤔 . There are places where you need tree structure but there is not one and you have to preserve some state while iterating over |
* Log the depth of elements as they're fetched * Log the starting depth of structs/enums and their Rust symbol names (not just XML element names, which may differ significantly) * Log every element in the struct/enum match loop at trace level. * Log file/line numbers at a few key points in the tests. This is helpful in finding failures happen in some of the longer tests. This logging helps me understand the data flow as I play with changes for luminvent#76.
* Log the depth of elements as they're fetched * Log the starting depth of structs/enums and their Rust symbol names (not just XML element names, which may differ significantly) * Log every element in the struct/enum match loop at trace level. * Log file/line numbers at a few key points in the tests. This is helpful in finding failures happen in some of the longer tests. This logging helps me understand the data flow as I play with changes for luminvent#76.
Hello @scottlamb and @DmitrySamoylov ! Very interesting discussion in this thread. I have used xml-rs because basically the serde-xml was based on it, and helped me to start the project. Do you have time next week for a meeting to discuss on all needed points ? Best |
Hmm, meetings are a little hard for me. I'm working on this for my Moonfire NVR project. It's my personal project, and my employer's copyright release agreement specifies I can't use their resources / time for it. I generally interpret that as not during the standard workday unless I take a vacation day. I'm a little too behind at work for that right now, so a meeting would have to be on the weekend or early morning / late evening Pacific time. |
Would you still like to meet (and I apologize for my inconvenient time requirements) or should we converse over email/issues instead? |
I find it useful to have a more extended example that works easily out of the box. In particular, one that: * supports authentication for everything. My cameras require it for almost all operations, so eg get_stream_uri didn't work. * uses real argument parsing so usage is more obvious. * automatically finds the right URIs for the different SOAP services. Also unlike the README examples, my cameras don't let you send everything to the root path. * supports a couple longer operations. They're admittedly a little arbitrary. Not everything works as of this commit, due to luminvent/yaserde#76 and at least one other problem.
I find it useful to have a more extended example that works easily out of the box. In particular, one that: * supports authentication for everything. My cameras require it for almost all operations, so eg get_stream_uri didn't work. * uses real argument parsing so usage is more obvious. * automatically finds the right URIs for the different SOAP services. Also unlike the README examples, my cameras don't let you send everything to the root path. * supports a couple longer operations. They're admittedly a little arbitrary. Not everything works as of this commit, due to luminvent/yaserde#76 and at least one other problem.
I just started a much more ambitious proposal in #84; I'm eager to hear your thoughts on it. |
`Extension` inside `Extension` causes infinite loop at deserialization: luminvent/yaserde#76 #64
Is it possible to check if the #112 fixes it ? |
I use the version 0.7.1, which includes this commit, and the problem is still not fixed when using such a example
|
This onvif-rs crate was unable to parse the message below, with an error "unknown event EndDocument". Note that crate is using yaserde 137af01.
I got it down to a failing yaserde test. It's quite similar to the existing
de_same_field_name_sub_sub
test. Looks like an onvif-rs owner/contributor @DmitrySamoylov added this as part of #51 talking about a related problem. But it seems to still be broken when there are these other fields present.With yaserde at that revision (137af01), I see the same error as in my "real" message.
With yaserde at current master (2726de5), it still doesn't work, but the symptom is different: it goes into a busy-loop during this test.
I haven't diagnosed further than this.
The text was updated successfully, but these errors were encountered: