Skip to content
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

Fix UnexpectedEof when deserialize xs:lists and newtypes #660

Merged
merged 7 commits into from
Oct 6, 2023

Conversation

Mingun
Copy link
Collaborator

@Mingun Mingun commented Oct 4, 2023

The problem with #590 was in SeqItemDeserializer::deserialize_newtype_struct. Previously it was the same as SeqItemDeserializer::deserialize_seq, but deserializing sequences in this deserializer assumes, that those sequences are xs:lists, because deserializer itself represents a list element.

Also, I noticed, that <tag></tag> (or <tag/>) could return and error when try to deserialize xs:list from it. Funny, that due to incorrect implementation instead of Unsupported("unsupported event End") the UnexpectedEof was returned.

Fixes #580

…zer and SeqItemDeserializer

in deserialize_primitives! macro, because each deserializer should implement it the same as it's
own deserialize_struct method
…ize_any

deserialize_map already handles unwanted events gracefully, no need to process
them outside of it
…sentation

failures:

---- fixed_name::fixed_size::xs_list::empty stdout ----
[tests\helpers\mod.rs:14] source = "\n                    <root>\n                        <item/>\n                    </root>\n                    "
thread 'fixed_name::fixed_size::xs_list::empty' panicked at tests/serde-de-seq.rs:871:18:
called `Result::unwrap()` on an `Err` value: UnexpectedEof
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- fixed_name::variable_size::xs_list::empty stdout ----
[tests\helpers\mod.rs:14] source = "\n                    <root>\n                        <item/>\n                    </root>\n                    "
thread 'fixed_name::variable_size::xs_list::empty' panicked at tests/serde-de-seq.rs:1697:18:
called `Result::unwrap()` on an `Err` value: UnexpectedEof

---- variable_name::fixed_size::xs_list::empty stdout ----
[tests\helpers\mod.rs:14] source = "\n                    <root>\n                        <item/>\n                    </root>\n                    "
thread 'variable_name::fixed_size::xs_list::empty' panicked at tests/serde-de-seq.rs:2967:18:
called `Result::unwrap()` on an `Err` value: UnexpectedEof

---- variable_name::variable_size::xs_list::empty stdout ----
[tests\helpers\mod.rs:14] source = "\n                    <root>\n                        <item/>\n                    </root>\n                    "
thread 'variable_name::variable_size::xs_list::empty' panicked at tests/serde-de-seq.rs:4066:18:
called `Result::unwrap()` on an `Err` value: UnexpectedEof

failures:
    fixed_name::fixed_size::xs_list::empty
    fixed_name::variable_size::xs_list::empty
    variable_name::fixed_size::xs_list::empty
    variable_name::variable_size::xs_list::empty
…g/> or <tag></tag>)

Document the MapValueDeserializer and SeqItemDeserializer. The deserializers does not yet
fully follows their descriptions, but that will be fixed in next commits
---- issue580 stdout ----
thread 'issue580' panicked at tests/serde-issues.rs:412:10:
called `Result::unwrap()` on an `Err` value: Custom("invalid length 0, expected tuple struct Wrapper with 1 element")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    issue580
…ct instead of visit_seq

The problem was in `SeqItemDeserializer::deserialize_newtype_struct`. Previously it was
the same as `SeqItemDeserializer::deserialize_seq`, but deserializing sequences in this
deserializer assumes, that those sequences are `xs:list`s, because deserializer itself
represents a list element.

In the original bug report an `UnexpectedEof` is returning. The error was changed in the
pre-previous commit (3d5ed69) and in this it is fixed.

The following tests checks that all's OK:

- Deserializer::deserialize_newtype_struct is reached by:
  - serde-de:
    - newtype::excess_attribute
    - newtype::simple
  - serde-se:
    - with_root::newtype
    - without_root::newtype

- MapValueDeserializer::deserialize_newtype_struct is reached by:
  - serde-issues:
    - issue343

- SeqItemDeserializer::deserialize_newtype_struct is reached by:
  - serde-issues:
    - issue580
@Mingun Mingun added bug serde Issues related to mapping from Rust types to XML labels Oct 4, 2023
@Mingun
Copy link
Collaborator Author

Mingun commented Oct 4, 2023

Deserializers are still does not fully follow updated documentation for them. They will be aligned with it in the following PR for #567.

@Mingun Mingun merged commit dd34cab into tafia:master Oct 6, 2023
6 checks passed
@Mingun Mingun deleted the fix-580 branch October 6, 2023 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug serde Issues related to mapping from Rust types to XML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UnexpectedEof error on 0.28.
1 participant