Skip to content

Commit 8491520

Browse files
authored
Deny unknown fields (#272) (#349)
1 parent 221fe5b commit 8491520

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

Diff for: buildpacks/ruby/src/layers/shared.rs

+1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ mod tests {
207207

208208
/// Struct for asserting the behavior of `cached_layer_write_metadata`
209209
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)]
210+
#[serde(deny_unknown_fields)]
210211
struct TestMetadata {
211212
value: String,
212213
}

Diff for: buildpacks/ruby/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ impl From<RubyBuildpackError> for libcnb::Error<RubyBuildpackError> {
285285
buildpack_main!(RubyBuildpack);
286286

287287
#[derive(serde::Deserialize, serde::Serialize, Debug, Clone, PartialEq, Eq)]
288+
#[serde(deny_unknown_fields)]
288289
struct BundleWithout(String);
289290

290291
impl BundleWithout {

Diff for: commons/src/gemfile_lock.rs

+2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl GemfileLock {
8181
}
8282

8383
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
84+
#[serde(deny_unknown_fields)]
8485
pub struct ResolvedRubyVersion(pub String);
8586

8687
impl Display for ResolvedRubyVersion {
@@ -90,6 +91,7 @@ impl Display for ResolvedRubyVersion {
9091
}
9192

9293
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
94+
#[serde(deny_unknown_fields)]
9395
pub struct ResolvedBundlerVersion(pub String);
9496

9597
impl Display for ResolvedBundlerVersion {

Diff for: commons/src/metadata_digest.rs

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ const PLATFORM_ENV_VAR: &str = "user configured environment variables";
148148
/// add logic to your buildpack to re-run that command similar to the "escape valve" discussed
149149
/// above, but triggered by buildpack author instead of the end user.
150150
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
151+
#[serde(deny_unknown_fields)]
151152
pub struct MetadataDigest {
152153
platform_env: Option<PlatformEnvDigest>,
153154
files: Option<PathsDigest>, // Must be last for serde to be happy https://github.com/toml-rs/toml-rs/issues/142
@@ -235,9 +236,11 @@ impl MetadataDigest {
235236
}
236237

237238
#[derive(Serialize, Deserialize, Clone, Debug, Hash, PartialEq, Eq)]
239+
#[serde(deny_unknown_fields)]
238240
struct ShaString(String);
239241

240242
#[derive(Serialize, Deserialize, Clone, Debug, Hash, PartialEq, Eq)]
243+
#[serde(deny_unknown_fields)]
241244
struct PlatformEnvDigest(ShaString);
242245
impl PlatformEnvDigest {
243246
fn new(platform: &impl Platform) -> Self {
@@ -248,6 +251,7 @@ impl PlatformEnvDigest {
248251
}
249252

250253
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
254+
#[serde(deny_unknown_fields)]
251255
struct PathsDigest(HashMap<PathBuf, ShaString>);
252256

253257
/// Main struct for detecting changes between two iterations

0 commit comments

Comments
 (0)