Skip to content

Errors returned via ListStream only conditionally caught by try #16083

Open

Description

@dilr

Describe the bug

If a try/try-catch block is piped from, and a command inside the try block returns an error in a streaming fashion, then the error escapes the try block.

How to reproduce

try {
  open --raw $nu.current-exe | lines
} | where true

results in an error message about the file not being utf-8.

Expected behavior

I expected errors inside the try block to not propagate outside the try block, though it's not clear exactly what the correct behavior should be. Note that

try {
  open --raw $nu.current-exe | lines | where true
}

does not print an error message (as expected). It is only when the try block is piped from that the error escapes.

Also note that a non-streaming error such as

try {
  open /does/not/exist | lines
} | echo $in

does not print an error message either. In this case I used echo $in rather than where true because where does not accept empty pipelines.

My suggestion for the behavior in the case of streaming errors with try blocks is as follows: Using a try block would cause errors to be ignored (like do -i), while using a try catch block would cause the catch block to be used to generate a replacement value each time an error is encountered. There are surely other reasonable things that could be done though.

However, the current behavior makes try blocks occasionally ineffective for reasons that aren't obvious to anyone who doesn't know about PipelineData and the fact that errors are a type of Value, and so I feel as though it counts as a bug.

Configuration

key value
version 0.105.1
major 0
minor 105
patch 1
branch
commit_hash
build_os macos-x86_64
build_target x86_64-apple-darwin
rust_version rustc 1.89.0-nightly (bf64d66bd 2025-05-21)
rust_channel nightly-x86_64-apple-darwin
cargo_version cargo 1.89.0-nightly (47c911e9e 2025-05-14)
build_time 2025-06-23 19:42:48 -04:00
build_rust_channel release
allocator standard
features default, sqlite, trash
installed_plugins

Activity

  1. added
    status:needs-triage
    on Jul 1, 2025
  2. added
    A:error-handling
    A:streaming
    on Jul 2, 2025
  3. kronberger-droid commented on Nov 16, 2026

    @kronberger-droid
    Contributor

    The lines case from this report no longer errors, since lines is lossy now.
    The underlying problem is still there on 0.117:

    try { 1..3 | each {|x| if $x == 2 { error make {msg: boom} } else { $x } } } | where true

    fails with boom, while the same with a catch or with where inside the try is caught.

    AI:X EXECUTE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:error-handlingA:streamingstatus:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions