From d5fcb98e05b3be31b457f30e5a9dcae14f5c5105 Mon Sep 17 00:00:00 2001 From: Alexandre Frigon Date: Mon, 7 Sep 2026 00:46:11 -0400 Subject: [PATCH] report every managed property entry in one error Closes #21 --- docs/src/reference/manifest.md | 3 ++- src/manifest/mod.rs | 19 ++++++++++++------- src/manifest/tests.rs | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/docs/src/reference/manifest.md b/docs/src/reference/manifest.md index baa832b..e0278fc 100644 --- a/docs/src/reference/manifest.md +++ b/docs/src/reference/manifest.md @@ -196,7 +196,8 @@ must be quoted, as above; a nested block spells the same key, so Keys managed by mc are rejected: an entry for a key that a `server` field or the top-level `name` and `description` already drive is an error naming -the field to use instead. `enable-rcon` is rejected too — RCON is enabled +the field to use instead. Every managed entry is reported in the same +error, so one pass fixes them all. `enable-rcon` is rejected too — RCON is enabled exactly when an RCON password is configured (see [Environment Variables](./environment-variables.md)). diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index e259d8b..b980a5c 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -425,14 +425,19 @@ impl RawServer { flatten_properties(None, raw_properties, &mut properties)?; } - for (key, hint) in MANAGED_PROPERTY_KEYS { - if properties.contains_key(key) { - anyhow::bail!( + let managed: Vec = MANAGED_PROPERTY_KEYS + .iter() + .filter(|(key, _)| properties.contains_key(*key)) + .map(|(key, hint)| { + format!( "the `{}` entry in `properties` is managed by mc; {}", - key, - hint - ); - } + key, hint + ) + }) + .collect(); + + if !managed.is_empty() { + anyhow::bail!("{}", managed.join("\n")); } Ok(ManifestServer { diff --git a/src/manifest/tests.rs b/src/manifest/tests.rs index b0435bc..e69dfdb 100644 --- a/src/manifest/tests.rs +++ b/src/manifest/tests.rs @@ -597,6 +597,27 @@ fn managed_property_is_rejected() { ); } +#[test] +fn every_managed_property_is_reported_at_once() { + let source = with_section( + "server {\n properties {\n server-port 25566\n white-list #false\n enable-rcon #true\n }\n}" + ); + let message = error_message(Manifest::from_kdl_str(&source)); + + assert!( + message.contains("the `server-port` entry in `properties` is managed by mc; set `port` in `server` instead"), + "{message}" + ); + assert!( + message.contains("the `white-list` entry in `properties` is managed by mc; set `allow-list` in `server` instead"), + "{message}" + ); + assert!( + message.contains("the `enable-rcon` entry in `properties` is managed by mc; rcon is enabled when a rcon password is configured"), + "{message}" + ); +} + #[test] fn rcon_password_property_is_rejected() { let source =