-
Notifications
You must be signed in to change notification settings - Fork 221
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
Incorrect deserialization with yaml feature and keys containing periods #417
Comments
Hi! Thanks for your report. Would you mind filing a patch showcasing this? I would be especially interested in a comparison of Can all be in one testcase, in one file in If you cannot spare the time for this, just ping me and I'll do it myself. |
I expected |
Ah yeah, then that crate of course. Sorry, I maintain so many projects that I lose track sometimes and I didn't look it up. My bad. |
Digging into this deeper, it also appears |
Awesome! So it seems that we should switch YAML implementations at some point. Maybe it is worth doing this even though there's a rewrite ongoing (although slowly, #376) where we could use ... just thinking loud here. |
…arse key containing periods in yaml
Alright, repro added to tests with |
For reference, the source of the problem has been identified: #418 (comment) Switching YAML parser won't resolve this. UPDATE: You can use keys with dots/periods if they're not defined at top-level. Although as referenced below, it's considered a bug (even though it'd seem necessary for the serde rename feature to work correctly to avoid This issue is also a duplicate where the cause was explained:
#[derive(Debug, Deserialize)]
struct Test {
toplevel: Nested,
}
#[derive(Debug, Deserialize)]
struct Nested {
#[serde(rename = "192.168.1.1")]
ip_key: String,
#[serde(rename = "hello.world")]
hello_world: String,
nested: String,
} Input: toplevel:
hello.world: example
192.168.1.1: a string value
toplevel.nested: valid Outputs:
|
When using
yaml
as a config format, the deserialization incorrectly stops at periods in keys. I do not observe this behavior when manually deserializing the string withserde_yaml
or other deserializers (such asruamel.yaml
orpyyaml
in Python). As a result, I am getting errors about keys not being present in the mapped value even though they definitely exist.MCVE:
Result:
The text was updated successfully, but these errors were encountered: