Skip to content

Commit

Permalink
feat: check VRL conditions at compile time
Browse files Browse the repository at this point in the history
  • Loading branch information
pront committed Jul 6, 2023
1 parent 9ec0443 commit 7611c05
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/conditions/vrl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 7611c05

Please sign in to comment.