Skip to content

Commit 4f60713

Browse files
authored
fix(config): deny unknown fields (#203)
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 7f315e3 commit 4f60713

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/src/config.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use crate::NonZeroGRT;
2222

2323
#[derive(Debug, Deserialize)]
2424
#[cfg_attr(test, derive(PartialEq))]
25+
#[serde(deny_unknown_fields)]
2526
pub struct Config {
2627
pub indexer: IndexerConfig,
2728
pub database: DatabaseConfig,
@@ -120,32 +121,37 @@ impl Config {
120121

121122
#[derive(Debug, Deserialize)]
122123
#[cfg_attr(test, derive(PartialEq))]
124+
#[serde(deny_unknown_fields)]
123125
pub struct IndexerConfig {
124126
pub indexer_address: Address,
125127
pub operator_mnemonic: Mnemonic,
126128
}
127129

128130
#[derive(Debug, Deserialize)]
129131
#[cfg_attr(test, derive(PartialEq))]
132+
#[serde(deny_unknown_fields)]
130133
pub struct DatabaseConfig {
131134
pub postgres_url: Url,
132135
}
133136

134137
#[derive(Debug, Deserialize)]
135138
#[cfg_attr(test, derive(PartialEq))]
139+
#[serde(deny_unknown_fields)]
136140
pub struct GraphNodeConfig {
137141
pub query_url: Url,
138142
pub status_url: Url,
139143
}
140144

141145
#[derive(Debug, Deserialize)]
142146
#[cfg_attr(test, derive(PartialEq))]
147+
#[serde(deny_unknown_fields)]
143148
pub struct MetricsConfig {
144149
pub port: u16,
145150
}
146151

147152
#[derive(Debug, Deserialize)]
148153
#[cfg_attr(test, derive(PartialEq))]
154+
#[serde(deny_unknown_fields)]
149155
pub struct SubgraphsConfig {
150156
pub network: NetworkSubgraphConfig,
151157
pub escrow: EscrowSubgraphConfig,
@@ -154,6 +160,7 @@ pub struct SubgraphsConfig {
154160
#[serde_as]
155161
#[derive(Debug, Deserialize)]
156162
#[cfg_attr(test, derive(PartialEq))]
163+
#[serde(deny_unknown_fields)]
157164
pub struct NetworkSubgraphConfig {
158165
#[serde(flatten)]
159166
pub config: SubgraphConfig,
@@ -164,6 +171,7 @@ pub struct NetworkSubgraphConfig {
164171

165172
#[derive(Debug, Deserialize)]
166173
#[cfg_attr(test, derive(PartialEq))]
174+
#[serde(deny_unknown_fields)]
167175
pub struct EscrowSubgraphConfig {
168176
#[serde(flatten)]
169177
pub config: SubgraphConfig,
@@ -172,6 +180,7 @@ pub struct EscrowSubgraphConfig {
172180
#[serde_as]
173181
#[derive(Debug, Deserialize)]
174182
#[cfg_attr(test, derive(PartialEq))]
183+
#[serde(deny_unknown_fields)]
175184
pub struct SubgraphConfig {
176185
pub query_url: Url,
177186
pub deployment_id: Option<DeploymentId>,
@@ -194,13 +203,15 @@ pub enum TheGraphChainId {
194203

195204
#[derive(Debug, Deserialize)]
196205
#[cfg_attr(test, derive(PartialEq))]
206+
#[serde(deny_unknown_fields)]
197207
pub struct BlockchainConfig {
198208
pub chain_id: TheGraphChainId,
199209
pub receipts_verifier_address: Address,
200210
}
201211

202212
#[derive(Debug, Deserialize)]
203213
#[cfg_attr(test, derive(PartialEq))]
214+
#[serde(deny_unknown_fields)]
204215
pub struct ServiceConfig {
205216
pub serve_network_subgraph: bool,
206217
pub serve_escrow_subgraph: bool,
@@ -214,13 +225,15 @@ pub struct ServiceConfig {
214225
#[serde_as]
215226
#[derive(Debug, Deserialize)]
216227
#[cfg_attr(test, derive(PartialEq))]
228+
#[serde(deny_unknown_fields)]
217229
pub struct ServiceTapConfig {
218230
/// what's the maximum value we accept in a receipt
219231
pub max_receipt_value_grt: NonZeroGRT,
220232
}
221233

222234
#[derive(Debug, Deserialize)]
223235
#[cfg_attr(test, derive(PartialEq))]
236+
#[serde(deny_unknown_fields)]
224237
pub struct TapConfig {
225238
/// what is the maximum amount the indexer is willing to lose in grt
226239
pub max_amount_willing_to_lose_grt: NonZeroGRT,
@@ -243,6 +256,7 @@ impl TapConfig {
243256
#[serde_as]
244257
#[derive(Debug, Deserialize)]
245258
#[cfg_attr(test, derive(PartialEq))]
259+
#[serde(deny_unknown_fields)]
246260
pub struct RavRequestConfig {
247261
/// what divisor of the amount willing to lose to trigger the rav request
248262
pub trigger_value_divisor: BigDecimal,

0 commit comments

Comments
 (0)