Skip to content

Commit

Permalink
Deny unknown fields in package configurations
Browse files Browse the repository at this point in the history
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 science-computing#188.

[0]: rust-cli/config-rs#450
[1]: https://serde.rs/container-attrs.html#deny_unknown_fields

Signed-off-by: Michael Weiss <michael.weiss@atos.net>
  • Loading branch information
primeos-work committed Aug 29, 2023
1 parent 8b70020 commit b075e97
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/package/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b075e97

Please sign in to comment.