Skip to content

Change ListStream iterator item from Value to Result<Value, ShellError> - #16803

Closed
132ikl wants to merge 6 commits into
nushell:mainfrom
132ikl:liststream-shellerror
Closed

132ikl wants to merge 6 commits into
nushell:mainfrom
132ikl:liststream-shellerror

Conversation

@132ikl

@132ikl 132ikl commented Oct 3, 2025 •

Copy link
Copy Markdown
Member

This PR changes the iteration type of ListStream from Value to Result<Value, ShellError>. Currently, the only way to express errors within a ListStream is to put them into a Value::Error, which causes errors to get stuck inside of streams, resulting in lots of confusing situations. #16738 improved this situation by making it an error to collect streams with errors, but this PR takes this a step further by making it possible to return actual ShellErrors in the ListStream iterator. These can then be properly handled by the consumer of the ListStream iterator.

This PR also opens up a path towards removing Value::Error altogether, if that is a direction we are interested in going.

This is a currently a draft PR, the core implementation of the ListStream and related functions has already been changed (nu-protocol and nu-engine both compile already), but almost every place where ListStream is iterated over directly needs to be modified to unwrap the Results.

The PipelineData::map function still retains the same signature (Value -> Value). There is also a new PipelineData::try_map function (Value -> Result<Value, ShellError>), which will let us replace any PipelineData::map invocation which constructs a Value::Error with a PipelineData::try_map invocation which can return a proper ShellError.

Release notes summary - What our users need to know

TODO

@132ikl 132ikl added A:error-handling How errors in externals/nu code are caught or handled programmatically (see also unhelpful-error) A:streaming Issues related to streaming data (or collecting data when it should be streamed) category:refactor labels Oct 3, 2025
@132ikl

132ikl commented Oct 3, 2025

Copy link
Copy Markdown
Member Author

curious to see if @cptpiepmatz and @sholderbach have thoughts about direction

@cptpiepmatz

Copy link
Copy Markdown
Member

This sadly never left draft status. And sorry for not looking into this 😭

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

Labels

A:error-handling How errors in externals/nu code are caught or handled programmatically (see also unhelpful-error) A:streaming Issues related to streaming data (or collecting data when it should be streamed) category:refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants