Skip to content

Commit 94b1b91

Browse files
committed
Deny unknown fields in repository config
1 parent 41f23c0 commit 94b1b91

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub const CONFIG_FILE_PATH: &str = "rust-bors.toml";
1111
/// Configuration of a repository loaded from a `rust-bors.toml`
1212
/// file located in the root of the repository file tree.
1313
#[derive(serde::Deserialize, Debug)]
14+
#[serde(deny_unknown_fields)]
1415
pub struct RepositoryConfig {
1516
/// Maximum duration (in seconds) to wait for CI checks to complete before timing out.
1617
/// Defaults to 3600 seconds (1 hour).
@@ -268,6 +269,13 @@ try = ["foo"]
268269
"#);
269270
}
270271

272+
#[test]
273+
#[should_panic(expected = "unknown field `labels-blocking-approval`")]
274+
fn deserialize_unknown_key_fail() {
275+
let content = r#"labels-blocking-approval = ["foo", "bar"]"#;
276+
load_config(content);
277+
}
278+
271279
fn load_config(config: &str) -> RepositoryConfig {
272280
toml::from_str(config).unwrap()
273281
}

0 commit comments

Comments
 (0)