From 7611c05eb8a91369329ad23081e3c6e9ebceb755 Mon Sep 17 00:00:00 2001 From: Pavlos Rontidis Date: Thu, 6 Jul 2023 11:38:36 -0400 Subject: [PATCH] feat: check VRL conditions at compile time --- src/conditions/vrl.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/conditions/vrl.rs b/src/conditions/vrl.rs index 3fb115e7ba7fc..5febe5ef1a222 100644 --- a/src/conditions/vrl.rs +++ b/src/conditions/vrl.rs @@ -63,6 +63,10 @@ impl ConditionalConfig for VrlConfig { .to_string() })?; + if !program.final_type_info().result.is_boolean() { + return Err("VRL conditions must return a boolean.".into()); + } + if !warnings.is_empty() { let warnings = Formatter::new(&self.source, warnings).colored().to_string(); warn!(message = "VRL compilation warning.", %warnings); @@ -233,6 +237,12 @@ mod test { Ok(()), Ok(()), ), + ( + log_event![], + r#""i_return_a_string""#, + Err("VRL conditions must return a boolean.".into()), + Ok(()), + ), ]; for (event, source, build, check) in checks {