Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make is_json more permissive #501

Open
shend-block opened this issue Oct 10, 2023 · 0 comments
Open

Make is_json more permissive #501

shend-block opened this issue Oct 10, 2023 · 0 comments
Labels
vrl: stdlib Changes to the standard library

Comments

@shend-block
Copy link

Currently the documentation states is_json is a infallible function call. However passing in a argument without casting as a string will fail

Running tests
2023-10-10T18:25:59.580454Z ERROR vector::unit_test: Failed to execute tests:
Failed to build test 'test_transforms':
  failed to create test condition '0': 
  error[E630]: fallible argument
    ┌─ :1:9
    │
  1 │ assert!(is_json(.actor))
    │         ^^^^^^^^^^^^^^^
    │         │
    │         this expression can fail
    │         handle the error before passing it in as an argument
    │
    = see documentation about error handling at https://errors.vrl.dev/#handling
    = see language documentation at https://vrl.dev
    = try your code in the VRL REPL, learn more at https://vrl.dev/examples
  .
~/Development/ccd-security-lake shend/okta *+ vector --version
vector 0.33.0 (x86_64-apple-darwin 89605fb 2023-09-27 14:18:24.180809939)

When casting the argument as a string using string! it passes

assert!(is_json(string!(.actor)))

Would it make sense to have is_json() check if the argument as a string and return false if its not?

@jszwedko jszwedko added the vrl: stdlib Changes to the standard library label Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vrl: stdlib Changes to the standard library
Projects
None yet
Development

No branches or pull requests

2 participants