Repository navigation
Description
Describe the bug
When a where predicate raises a type error, where emits a stream of error values
rather than failing. Some downstream consumers propagate that error correctly, but
length, columns and is-empty silently consume the error values and return a
wrong answer with exit code 0.
The practical consequence is silent data loss: a pipeline can report that a filter
matched N rows and then produce nothing (or everything), with no error anywhere.
How to reproduce
# `size` is a filesize; `150` is an int. The comparison is a type error.
[[name size]; [a 100b] [b 200b]] | where size <= 150 | describe
# => list<error> (stream)Consumers disagree about what to do with that stream:
| pipeline | expected | actual |
|---|---|---|
... | where size <= 150 | length |
error, or 1 |
2 |
... | where size <= 150 | columns |
error | empty list |
... | where size <= 150 | is-empty |
error | false |
... | where size <= 150 | first |
error | error ✅ |
... | where size <= 150 | get name |
error | error ✅ |
... | where size <= 150 | to json |
error | error ✅ |
... | where size <= 150 | to nuon |
error | error ✅ |
length returning 2 is the most damaging: it reports the unfiltered row count,
so the filter looks like it ran and matched everything.
The correct comparison behaves properly:
[[name size]; [a 100b] [b 200b]] | where size <= 150b | length
# => 1Not specific to filesize — any incompatible predicate type does it:
[[d]; [1sec] [2sec]] | where d <= 5 | length # => 2
[[a]; ["x"] ["y"]] | where a <= 5 | length # => 2Outside of where, the same comparison errors immediately, as expected:
100b <= 150
# Error: nu::shell::operator_incompatible_types
# x Types 'filesize' and 'int' are not compatible for the '<=' operator.Expected behavior
where should surface the predicate's type error. Failing that, every consumer of a
list<error> stream should propagate rather than silently counting or discarding the
error values.
How I found it
Filtering idx files (whose size column is a filesize) with an int bound:
idx files | where size <= 2000000 | length # => 2466 (looks fine)
idx files | where size <= 2000000 | each { ... } # => produces nothing
idx files | where size <= 2MB | each { ... } # => worksThe length check reported all 2466 rows surviving the filter, so the filter appeared
correct, while the actual pipeline silently wrote an empty table and exited 0.
Configuration
version | 0.115.0
platform | x86_64-unknown-linux-gnu (NixOS, Linux 6.18.45)
Reproduced with nu --no-config-file.
Possibly related
sort-by {length}on list of strings doesn't result in error #14462 —sort-by {length}on a list of strings silently returns the original listfindsilences errors #15618 —findsilences errors
Activity
getreu commentedon Aug 29, 2026
Additional context after finding the prior art — this is narrower and more general
than the original report suggests, so I've retitled it.
whereis incidentalThe same failure reproduces with no
whereinvolved:lengthreporting10is the damaging one: it counts error values as though theywere data.
This is a gap left by #16738
#16738 ("collecting a stream with an error raises an error", milestone v0.108.0) is
working correctly on 0.115.0 — its release-note example errors as intended:
firstpropagates correctly too, for the same reason.But that guard only fires on collection into a value.
length,columnsandis-emptyconsume the stream without collecting it, so they never hit the check andsilently return an answer computed from error values. The PR description says it
"fixes similar bugs everywhere" — these three consumers appear to be the everywhere
it didn't reach.
Relationship to other issues
ValuetoResult<Value, ShellError>#16803 — proposes changing theListStreamitem type fromValuetoResult<Value, ShellError>, and describes precisely this root cause: with errorsonly expressible as
Value::Error, they "get stuck inside of streams." That changewould fix this class structurally.
tryblock viaListStream. Opposite symptom, samemechanism (errors as stream values, handled inconsistently per consumer).
eachnot stopping the loop.The original
where size <= 150repro in the issue body still stands; it's just oneway to manufacture the error stream rather than the defect itself.
Tested on 0.115.0,
nu --no-config-file.[-]`where` emits error values that `length`, `columns` and `is-empty` silently swallow[/-][+]`length`, `columns` and `is-empty` silently consume error streams (gap after #16738)[/+]fdncred commentedon Aug 31, 2026
Would like to see this fixed. Thanks!
fix: propagate error stream values in length, columns, and is-empty (#…