Skip to content

range expression with invalid input produces infinite output instead of error #326

@derekleverenz

Description

@derekleverenz

If i give range an invalid input, it produces a seemingly infinite sequence of numbers as output, until i terminate it (saw this in an embedded usecase too, where it ended up with the process being killed for OOM) eg:

echo '{"a": 1}' | jaq 'range(.)'

produces a sequence starting from 0 and never terminating. Also replicated with an empty object {}, empty array [], and array with data as inputs.

the jq tool produces an error. echo '{"a": 1}' | jq 'range(.)' results in jq: error (at <stdin>:1): Range bounds must be numeric

This is with jaq 2.3.0, compiled from source via cargo install --locked jaq. Rustc version 1.89, ubuntu linux 22.04, x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions