Open
Description
A note for the community
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment.
Problem
The output type of format_int
seems to be integer
instead of string
.
Probably caused by its TypeDef
being integer
instead of bytes
:
Line 103 in 07cd43a
Since the tests also use the same TypeDef::integer()
type :
Line 147 in 07cd43a
This is also in contradiction with vector's documentation: https://github.com/vectordotdev/vector/blob/2a85007ce5c0ea05cdb408f4d6c898049c33f055/website/cue/reference/remap/functions/format_int.cue#L27.
VRL Program
b, err_b = format_int(.b.value, 2)
c, err_c = to_string(.c.value)
# both are considered strings
.b.is_string = is_string(b)
.c.is_string = is_string(c)
# not ints
.b.is_int = is_integer(b)
.c.is_int = is_integer(c)
# cannot fail so no error catching needed
if is_null(err_c) {
.c.string = string(c)
}
# can fail, although its return type is the same as `to_string`
if is_null(err_b) {
.b.string = string(b)
}
VRL and/or Vector Version
vrl 0.22 (vector 0.45.0)
Debug Output
error[E103]: unhandled fallible assignment
┌─ :19:16
│
19 │ .b.string = string(b)
│ ----------- ^^^^^^^^^ this expression is fallible because at least one argument's type cannot be verified to be valid
│ │
│ or change this to an infallible assignment:
│ .b.string, err = string(b)
│
= see documentation about error handling at https://errors.vrl.dev/#handling
= see functions characteristics documentation at https://vrl.dev/expressions/#function-call-characteristics
= learn more about error code 103 at https://errors.vrl.dev/103
= see language documentation at https://vrl.dev
= try your code in the VRL REPL, learn more at https://vrl.dev/examples
Example
Additional Context
No response
References
Possible solution: https://github.com/JTKU/vrl/tree/fix_format_int_output_type