From 925ddb7c7f6a24148f67ce78d812f609ada943fc Mon Sep 17 00:00:00 2001 From: Ragnor Comerford Date: Wed, 3 Jun 2026 16:21:59 +0200 Subject: [PATCH] test(config): legacy config with unknown field must load (red) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A config without a `version:` is the legacy/lenient schema (RFC-002): an unrecognized top-level key must be tolerated, not rejected. This test pins that contract and fails today because `deny_unknown_fields` is applied unconditionally (struct-wide), so the `version` discriminator does not actually gate strictness. Intentionally red — goes green in the next commit, which gates unknown-field strictness on `version`. --- crates/omnigraph-config/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/omnigraph-config/src/lib.rs b/crates/omnigraph-config/src/lib.rs index 3e0abca..7e8c793 100644 --- a/crates/omnigraph-config/src/lib.rs +++ b/crates/omnigraph-config/src/lib.rs @@ -1279,6 +1279,22 @@ cli: ); } + #[test] + fn legacy_config_tolerates_unknown_fields() { + // No `version:` ⇒ legacy schema: an unrecognized key is tolerated, not + // rejected (RFC-002: a missing `version:` is the lenient legacy shape). + // Pins the contract that `version` — not an unconditional struct + // attribute — gates strictness; a `version: 1` config rejects the same + // key (see `version_one_rejects_unknown_nested_field`). A top-level key + // is used deliberately: that is the level a struct-wide + // `deny_unknown_fields` catches today, so this reproduces the bug. + let config = load_yaml( + "graphs:\n local:\n uri: ./demo.omni\n\ + future_top_level_key: whatever\ncli:\n graph: local\n", + ); + assert_eq!(config.cli_graph_name(), Some("local")); + } + fn load_yaml(yaml: &str) -> super::OmnigraphConfig { let temp = tempdir().unwrap(); fs::write(temp.path().join("omnigraph.yaml"), yaml).unwrap();