Skip to content

fix: propagate stream errors in get skipped items - #19466

Closed
kokhlo wants to merge 1 commit into
nushell:mainfrom
kokhlo:fix/last-get-stream-errors-19463
Closed

kokhlo wants to merge 1 commit into
nushell:mainfrom
kokhlo:fix/last-get-stream-errors-19463

Conversation

@kokhlo

@kokhlo kokhlo commented Nov 6, 2026 •

Copy link
Copy Markdown

Description

get <n> (and $in.<n> cell-path access) silently dropped error values from stream items it skipped: a pipeline whose failing item came before the requested index still succeeded, and an exit inside the closure was discarded too. Fixes the get half of #19463.

Same class as the error propagation #18976 added for length, columns and is-empty.

PipelineData::follow_cell_path (nu-protocol) collected a ListStream with a plain .collect(), which keeps Value::Error items dormant inside the list, and then indexed it. It now collects with ListStream::into_value(), which propagates the first error. This also fixes $in.<n> cell-path access (same code path in eval_ir) and get with several paths.

The last half of #19463 is deliberately not included: the record family (#19190) codified that a failed row keeps its position and later rows are still processed — [{a: {b: x}} {c: 1}] | record walk {|value, path| ... } | last must return the last good row, not abort on the earlier error row. Propagating errors from evicted rows in last would contradict those tests, so it needs a maintainer call on the intended semantics (skip error rows vs. abort), not a one-line change. skip (also mentioned in #19463) is likewise a lazy-vs-eager design question.

User-facing changes (Release notes)

  • Fixed an issue where get <n> silently dropped errors (and discarded exit) from stream items before the requested index: [1 2 3] | each {|x| if $x == 1 { error make {msg: "boom"} }; $x } | get 2 now raises the error instead of returning 3, and exit 3 in a skipped item now exits with code 3 instead of the script continuing with exit code 0.

Additional notes

Fixes the get half of #19463 (last and skip need a semantics decision first — see Description).

Verification:

  • New regression test (RED on main, GREEN with the fix):
    • commands::get::get_index_propagates_errors_in_skipped_items
  • cargo test -p nu-command --test tests -- commands::get commands::last commands::record: 134 passed, 0 failed (includes the record family of commands #19190 record tests that a last change would have broken).
  • cargo test -p nu-protocol: 608 passed across all targets, 0 failed.
  • Manual run of the issue's exit cases against a debug build: each {|x| if $x == 1 { exit 1 }; $x } | get 2 exits 1 (was: printed 3, script continued); exit 3 variant exits 3.
  • cargo fmt and cargo clippy -p nu-command -p nu-protocol --all-targets -- -D warnings: clean.

@fdncred

fdncred commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

I think this is probably a bigger change than is in this PR. I think this is more widespread than just the last and get commands. I'm tinkering on a branch now too. We'll see how it goes.

#19467

@kokhlo kokhlo changed the title fix: propagate stream errors in last and get skipped items fix: propagate stream errors in get skipped items Nov 6, 2026
@kokhlo
kokhlo force-pushed the fix/last-get-stream-errors-19463 branch from 8438161 to 3d90b11 Compare November 6, 2026 15:52
@kronberger-droid

Copy link
Copy Markdown
Contributor

superseeded by #19467

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants