From b075e97b11d480e5292a13c6002f2d32d63c6dfb Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Tue, 29 Aug 2023 14:46:32 +0200 Subject: [PATCH] Deny unknown fields in package configurations This helps catching errors in package configuration files (`pkg.toml`) by rejecting unknown fields when loading the packages repository. The `config` crate is a bit limited in this regard but luckily this can be caught during deserialization via Serde [0][1]. The error output contains the path of the problematic package configuration file, the name of the unknown field, and a list of the valid/expected fields. Fixes #188. [0]: https://github.com/mehcode/config-rs/issues/450 [1]: https://serde.rs/container-attrs.html#deny_unknown_fields Signed-off-by: Michael Weiss --- src/package/package.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/package/package.rs b/src/package/package.rs index 91abf998..04ce8711 100644 --- a/src/package/package.rs +++ b/src/package/package.rs @@ -24,6 +24,7 @@ use crate::util::docker::ImageName; use crate::util::EnvironmentVariableName; #[derive(Clone, Serialize, Deserialize, Getters)] +#[serde(deny_unknown_fields)] pub struct Package { #[getset(get = "pub")] name: PackageName,