Repository navigation
fix: don't lose errors and exit from stream items a command drops - #19467
Merged
Merged
Conversation
Contributor
Author
|
@Tyarel8 I believe you had a change in this same area recently. Would you mind testing this to make things still work as expected? |
This was referenced Nov 6, 2026
Contributor
I have tried it a bit and seems to be working fine 👍 |
Contributor
Author
|
Thanks. I just wanted to make sure that I didn't accidentally undo your changes. |
12 tasks done
hakula139
added a commit
to hakulab/plugins
that referenced
this pull request
Nov 10, 2026
## Summary Two projects documented general Nushell conventions in their own `docs/conventions/nushell.md`, and the nushell skill now holds them, worded without project names, so those pages can keep only their project-specific rules: - **Scripts:** export only what another module or the module's own test calls, layer imports one way from the entry through domain modules to generic helpers, import a module by name when its commands share verbs with siblings and otherwise list the imported commands, and order a module's sections as the pipeline first reaches them with callees before callers. The Quoting bullet now makes double quotes the default, with single quotes for text holding a literal backslash or double quote, as a regex does, which agrees with the dynamic regex trap. - **Testing:** tests sit beside their module as `<module>.test.nu`, an entry script runs through `^$nu.current-exe`, an assertion compares the whole shape the test owns, and fixtures use a fixed day in UTC while the test sets `TZ` for the child process. - **Linting:** don't format with `nufmt`. It reindents to four spaces by default, and even with `indent: 2` it joins a pipeline split one stage per line, or a call split one option per line, onto one line, against the code-layout skill. The stream trap now names `skip` beside `get <n>` and `last`, since it too runs and discards a skipped item's error, and links the upstream issue, nushell/nushell#19463. Its fix, nushell/nushell#19467, is in no release yet. The skill had grown long, so a second commit groups it under task headings without changing a bullet: Scripts splits into entry and help, modules and imports, layout and order, quoting and strings, and paths. The two long trap groups split into `####` subsections, and Testing into layout and assertions, inputs and fixtures, and the nu-test runner. No link in this repository or in devkit points at an anchor in the skill. Project-specific items stay in their projects: module lists and dependency graphs, external tools, the config record, real `git init` repositories, the `edit-file` and file-URI `url encode` traps, and the `$env.HOME` override. Bump hakula-languages to 1.0.6, and add `nufmt` to the spelling dictionary. ## Test plan - [x] Commit and push hooks - [x] `nix develop -c run-hooks` - [x] `nix flake check --all-systems` - [x] `claude plugin validate .` - [x] On Nushell 0.116.1, `$nu.current-exe` names the dev shell's `nu`, the same path as `which nu` - [x] A child started with `with-env {TZ: ...} { ^$nu.current-exe entry.nu }` formats `date now` in that zone: `+00:00` for `UTC`, `+09:00` for `Asia/Tokyo`, and `-05:00` for `America/New_York` - [x] With `use ./cache.nu` and `use ./index.nu`, `cache read` and `index read` both resolve, `use ./paths.nu [path-map path-match]` leaves an unlisted export undefined, and `use ./cache.nu *` leaves a non-exported helper undefined - [x] `'a\d' == "a\\d"` and `'say "hi"' == "say \"hi\""` hold, and `"\d+"` fails to parse with `unrecognized escape sequence` - [x] `assert equal` fails on an extra record field and on an extra table row - [x] `nix shell nixpkgs#nufmt -c nufmt` (0.1.0) reindents a two-space file to four spaces, and with `{indent: 2}` as its config it still joins a split pipeline and a split `^git log` call onto one line each - [x] `[1 2 3] | each {|x| if $x == 1 { error make {msg: boom} } else { $x } } | skip 1 | to nuon` prints `[2, 3]` and exits 0 - [x] The reorganization changes no content line, since the sorted non-heading lines before and after it are identical. Against `main`, the sorted bullet labels differ only by the six added here (Assertions, Imports, Layout, Modules, Order, and Timestamps) and the stream trap's head that now names `skip`
6 tasks done
hakula139
added a commit
to hakulab/plugins
that referenced
this pull request
Nov 10, 2026
## Summary The nushell skill's stream trap now states the general pattern behind it, the traps gain a top-level syntax section and a separate environment section, and several examples and labels match the skill's own rules. - **Stream errors:** the trap now covers any command that pulls a stream item and discards it, which drops that item's `exit` or `error make`, with `get <n>`, `last`, `skip`, `drop`, and `select` as examples. It keeps the [nushell/nushell#19463](nushell/nushell#19463) link, points to [nushell/nushell#19467](nushell/nushell#19467) for the full list of affected commands, and adds `collect` before the command as the way to surface the error, while `first` stays the way to take a single match. - **Quoting example:** `into datetime --format "%s"` uses double quotes, as the skill's quoting rule asks. The remaining single-quoted examples hold a backslash (the regex piece), name the `$'...'` syntax, or show script arguments as shell input. - **Trap sections:** `### Syntax` now opens the traps, `### Parsing and data` becomes `### Data and types` with its `#### Streams and commands` renamed to `#### Commands`, and the `$nu.home-dir` trap moves into its own `### Environment` after External commands. - **Test files:** the **Layout** bullet becomes **Location** and names the file `<name>.test.nu`, matching the runner's `<name>.stub.nu`, and its subsection becomes "Files and assertions". - **Module order:** sections follow the order the entry first calls them, and the sentence on test-file order is gone, since the code-layout skill already orders tests by the code's order. - **Imports example:** the listed commands use invented names, `use ./paths.nu [path-split path-label]`. - **Timestamps:** the bullet now gives the reason a test sets `TZ` for the child process, since the running Nushell reads its zone only at startup. Bump hakula-languages to 1.0.7. ## Test plan - [x] Commit and push hooks, and `nix develop -c run-hooks` - [x] `nix flake check --all-systems` - [x] `claude plugin validate .` - [x] On the dev shell's Nushell 0.116.1, with `mk n` as `[1 2 3] | each {|x| if $x == n { error make {msg: boom} } else { $x } }`, `mk 3 | drop 1`, `mk 1 | select 1`, `mk 1 | skip 1`, `mk 1 | get 2`, `mk 1 | last`, `mk 1 | last 2`, and `mk 1 | drop nth 0` print results and exit 0, while `mk 1 | collect | skip 1`, `mk 3 | collect | drop 1`, and `mk 1 | collect | last` raise `boom` - [x] With a host zone of `+0800`, `$env.TZ = "Asia/Tokyo"` and `with-env {TZ: "Asia/Tokyo"} { date now | format date "%z" }` still print `+0800` in-process, while a child `^$nu.current-exe` under the same `with-env` prints `+0900` - [x] GitHub CI: Linux, macOS, and CI Result
…ation # Conflicts: # crates/nu-cli/src/util.rs # crates/nu-cmd-lang/src/core_commands/do_.rs # crates/nu-command/src/bytes/ends_with.rs # crates/nu-command/src/filters/chunks.rs # crates/nu-command/src/filters/last.rs # crates/nu-protocol/src/errors/shell_error/bridge.rs # crates/nu-protocol/src/pipeline/byte_stream.rs
This was referenced Nov 13, 2026
fdncred
added a commit
that referenced
this pull request
Nov 24, 2026
…`tee` (#19647) ## Description Since 0.114.0, `try` skips `catch` when it's piped into `ignore`, `complete`, `save` or `tee` and the error comes from the last command in its block. `finally` still runs, but it gets the raw error as its input and parameter, so the first command there that reads either one raises the error again. The case most likely to bite is a custom command that ends in a `try`. Call it as `my-command | ignore` and its `catch` never runs. #18306 made a command return its error as a value when its stderr goes to a separate pipe. That lets `ignore --stderr` decide what to do with the error. All four commands above ask for that separate pipe, and the last command in a `try` block inherits the redirection of whatever follows the `try`. So the error turned into a value, passed through `try` without reaching `catch`, and the next command raised it. Up to 0.117.0, a `;` after the pipeline discarded the error. #19467 stopped that, so on main the error surfaces. `try` now raises an error value that reaches the end of its block, or the end of `catch` before `finally`. The handlers run the same as they do without the pipe. When only `finally` handles the error, `finally` gets the error record. Then the error goes on to the next command as a value, the same as without `finally`, so `ignore --stderr` still consumes it. ## User-facing changes (Release notes) - Fixed `try` skipping `catch` when it's piped into `ignore`, `complete`, `save` or `tee`, including through a custom command that ends in a `try`. In the same case `finally` now gets the error record instead of the raw error. This was a regression in 0.114.0. - `try { ... } catch { 'fallback' } | ignore --stderr` now passes on `fallback` instead of consuming the error, and `try { exit 3 } | ignore --stderr` now exits. ## Additional notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A stream carries a failure as an item, so a command that read that item and then dropped it also dropped the failure.
last,get 2,skip 1and others returned a normal result with exit code 0. This was the gap #16738 and #18976 closed for collecting and forlength,columnsandis-empty.exitmakes it worse. Since #18389 (0.114.0)exittravels as an error instead of ending the process, so the same commands discarded it and the script kept running. 0.113.1 exits 7 on the commands below, and 0.114.0 carries on with exit code 0.Commands that read and drop an item now raise its error or pass it along, and commands that bury an item in a record or list now pass the error along instead.
;no longer ignores an error returned as a single value. A closure is never handed anexit, becausecatchcan't handle one and the closure could ignore it.do --ignore-errorsno longer ignoresexit. Items that never ran stay unevaluated, sofirstandtakeare as lazy as before.User-facing changes (Release notes)
last,get, cell paths on a stream,skip,skip while,skip until,take while,take until,select,drop,drop nth,slice,every,update,upsert,window,lines,zipandto text.enumerate,wrap,zip,chunks,chunk-by,windowandsplit listno longer hide a stream error inside the record or list they build.exitin its input once it finishes, soboom | to text | ^catraisesboomandtrycan catch it.do --ignore-errorsstill ignores the error, but notexit.take while,take until,skip while,skip until,chunk-by,split listandwhere, where it used to count asfalse.exitinside a closure always ends the script again, whichever command consumes the stream, anddo --ignore-errorsno longer ignores it.;no longer discards an error returned as a single value, andcatchnow sees errors fromfirstandlast.Breaking Changes
take while,take until,skip while,skip until,chunk-byorsplit listnow raises its error, aswherealready does. It used to count asfalse, so[{a: 1} {b: 2}] | take while {|r| $r.a == 1 }returned the first row and now reports the missing column. Use$r.a?for optional columns.last,skipor similar to get past an error now fails. To handle a failed item, useeach {|row| try { $row | ignore; $row } catch { ... } }.reverse,shuffle,sort-by,dropandlastnow raise an error item instead of keeping it among the rows, so thattryform has to come before them.to textnow raises an error instead of writing its debug form into the text, andeach {|y| $y; 'ok' }raises an error input instead of discarding it at the;.Additional notes
Closes #19463