Skip to content

Commit 522cfb1

Browse files
committed
Add serde deny_unknown_fields to Config
This adds deny_unknown_fields to Config so that any typo mistakes will be caught by the config validation.
1 parent 11aecef commit 522cfb1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/config.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ lazy_static::lazy_static! {
1717

1818
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
1919
#[serde(rename_all = "kebab-case")]
20+
#[serde(deny_unknown_fields)]
2021
pub(crate) struct Config {
2122
pub(crate) relabel: Option<RelabelConfig>,
2223
pub(crate) assign: Option<AssignConfig>,
@@ -38,6 +39,7 @@ pub(crate) struct Config {
3839
}
3940

4041
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
42+
#[serde(deny_unknown_fields)]
4143
pub(crate) struct NominateConfig {
4244
// team name -> label
4345
pub(crate) teams: HashMap<String, String>,
@@ -68,6 +70,7 @@ impl PingConfig {
6870
}
6971

7072
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
73+
#[serde(deny_unknown_fields)]
7174
pub(crate) struct PingTeamConfig {
7275
pub(crate) message: String,
7376
#[serde(default)]
@@ -76,6 +79,7 @@ pub(crate) struct PingTeamConfig {
7679
}
7780

7881
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
82+
#[serde(deny_unknown_fields)]
7983
pub(crate) struct AssignConfig {
8084
/// If `true`, then posts a warning comment if the PR is opened against a
8185
/// different branch than the default (usually master or main).
@@ -105,6 +109,7 @@ impl AssignConfig {
105109
}
106110

107111
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
112+
#[serde(deny_unknown_fields)]
108113
pub(crate) struct NoMergesConfig {
109114
/// No action will be taken on PRs with these substrings in the title.
110115
#[serde(default)]
@@ -121,6 +126,7 @@ pub(crate) struct NoMergesConfig {
121126
}
122127

123128
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
129+
#[serde(deny_unknown_fields)]
124130
pub(crate) struct NoteConfig {
125131
#[serde(default)]
126132
_empty: (),
@@ -133,6 +139,7 @@ pub(crate) struct MentionsConfig {
133139
}
134140

135141
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
142+
#[serde(deny_unknown_fields)]
136143
pub(crate) struct MentionsPathConfig {
137144
pub(crate) message: Option<String>,
138145
#[serde(default)]
@@ -141,18 +148,21 @@ pub(crate) struct MentionsPathConfig {
141148

142149
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
143150
#[serde(rename_all = "kebab-case")]
151+
#[serde(deny_unknown_fields)]
144152
pub(crate) struct RelabelConfig {
145153
#[serde(default)]
146154
pub(crate) allow_unauthenticated: Vec<String>,
147155
}
148156

149157
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
158+
#[serde(deny_unknown_fields)]
150159
pub(crate) struct ShortcutConfig {
151160
#[serde(default)]
152161
_empty: (),
153162
}
154163

155164
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
165+
#[serde(deny_unknown_fields)]
156166
pub(crate) struct PrioritizeConfig {
157167
pub(crate) label: String,
158168
}
@@ -176,6 +186,7 @@ impl AutolabelConfig {
176186
}
177187

178188
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
189+
#[serde(deny_unknown_fields)]
179190
pub(crate) struct AutolabelLabelConfig {
180191
#[serde(default)]
181192
pub(crate) trigger_labels: Vec<String>,
@@ -196,6 +207,7 @@ pub(crate) struct NotifyZulipConfig {
196207
}
197208

198209
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
210+
#[serde(deny_unknown_fields)]
199211
pub(crate) struct NotifyZulipLabelConfig {
200212
pub(crate) zulip_stream: u64,
201213
pub(crate) topic: String,
@@ -208,6 +220,7 @@ pub(crate) struct NotifyZulipLabelConfig {
208220
}
209221

210222
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
223+
#[serde(deny_unknown_fields)]
211224
pub(crate) struct MajorChangeConfig {
212225
/// A username (typically a group, e.g. T-lang) to ping on Zulip for newly
213226
/// opened proposals.
@@ -243,18 +256,22 @@ impl MajorChangeConfig {
243256
}
244257

245258
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
259+
#[serde(deny_unknown_fields)]
246260
pub(crate) struct GlacierConfig {}
247261

248262
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
263+
#[serde(deny_unknown_fields)]
249264
pub(crate) struct CloseConfig {}
250265

251266
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
267+
#[serde(deny_unknown_fields)]
252268
pub(crate) struct ReviewSubmittedConfig {
253269
pub(crate) review_labels: Vec<String>,
254270
pub(crate) reviewed_label: String,
255271
}
256272

257273
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
274+
#[serde(deny_unknown_fields)]
258275
pub(crate) struct ReviewRequestedConfig {
259276
pub(crate) remove_labels: Vec<String>,
260277
pub(crate) add_labels: Vec<String>,
@@ -280,6 +297,7 @@ pub(crate) async fn get(
280297

281298
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
282299
#[serde(rename_all = "kebab-case")]
300+
#[serde(deny_unknown_fields)]
283301
pub(crate) struct GitHubReleasesConfig {
284302
pub(crate) format: ChangelogFormat,
285303
pub(crate) project_name: String,

0 commit comments

Comments
 (0)