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

Incorrect error location when decoding certain fields with serde_yaml (serde_yaml bug) #426

Open
osa1 opened this issue Dec 30, 2023 · 0 comments
Labels

Comments

@osa1
Copy link
Owner

osa1 commented Dec 30, 2023

This was originally reported in #425.

#[test]
fn notify_field_error() {
    let server_config = r#"
addr: irc.libera.chat
join: []
extra1: a
extra2: b
notify: [mentions]
"#;
    match serde_yaml::from_str::<Server>(server_config) {
        Ok(ok) => {
            dbg!(ok);
            panic!("Config parsing should've been failed");
        }
        Err(err) => {
            dbg!(err);
        }
    }
}

(add this to crates/libtiny_tui/src/config.rs)

Here the problem is notify field is a sequence, but it should be a string.

The error currently looks like this: (tiny efa1d22, uses serde 1.0.193 and serde_yaml 0.8.26)

[crates/libtiny_tui/src/config.rs:538] err = Message(
    "invalid type: sequence, expected string or map",
    Some(
        Pos {
            marker: Marker {
                index: 5,
                line: 2,
                col: 4,
            },
            path: ".",
        },
    ),
)

Here the line number is incorrect, it should've been 5 (or 4 if it's 0 based).

This is a serde_yaml bug, first reported in 2019: dtolnay/serde-yaml#128.

To work around the bug, we could manually "flatten" the TabConfig type in server, channel, and default configs, keep this bug open, and revert the change if the bug in serde_yaml is fixed one day.

@osa1 osa1 added the bug label Dec 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant