redpanda-data / benthos

MIT License
179 stars 52 forks source link

Enhance linter errors for invalid root-level 'if` statements #64

Open mihaitodor opened 1 month ago

mihaitodor commented 1 month ago

Linting the following bloblang mapping:

if true { 
  deleted() 
} else {
  root.foo = 42
} 

produces the following error:

Input
Output
failed to parse mapping: line 4 char 12: required: expected }
  |
4 |   root.foo = 42
  |            ^---

Not sure if it's possible to enhance it without a breaking change though, because I think root = is implicit when there's no else clause (i.e. if true { deleted() })