Skip to content

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

Description

@osa1

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions