From 172a0c44bd08fe5de37c987cae7b6cfa638ec4c4 Mon Sep 17 00:00:00 2001 From: Bahex Date: Fri, 11 Jul 2025 19:32:31 +0300 Subject: [PATCH] fix(get): to be consistent with regular cell-path access on `null` values (#16155) # Description Cell-path accesses on `null` values throw an error, unless the initial cell-path member is optional: ```nushell ">"; (null).a # => Error: nu::shell::incompatible_path_access # => # => x Data cannot be accessed with a cell path # => ,-[source:1:8] # => 1 | (null).a # => : | # => : `-- nothing doesn't support cell paths # => `---- ">"; (null).a? | describe # => nothing ``` `get` throws an error on `null` even when the cell-path is optional, and only returns `null` quietly with the `--ignore-errors` flag ```nushell ">"; null | get a? # => Error: nu::shell::only_supports_this_input_type # => # => x Input type not supported. # => ,-[source:1:1] # => 1 | null | get a? # => : ^^|^ ^|^ # => : | `-- only table or record input data is supported # => : `-- input type: nothing # => `---- ">"; null | get -i a? | describe # => nothing ``` # Tests + Formatting No breakage. # After Submitting N/A Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com> --- crates/nu-command/src/filters/get.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/crates/nu-command/src/filters/get.rs b/crates/nu-command/src/filters/get.rs index 2f9a863991..ba770d1e66 100644 --- a/crates/nu-command/src/filters/get.rs +++ b/crates/nu-command/src/filters/get.rs @@ -172,18 +172,8 @@ fn action( } } - match input { - PipelineData::Empty => return Err(ShellError::PipelineEmpty { dst_span: span }), - // Allow chaining of get -i - PipelineData::Value(val @ Value::Nothing { .. }, ..) if !ignore_errors => { - return Err(ShellError::OnlySupportsThisInputType { - exp_input_type: "table or record".into(), - wrong_type: "nothing".into(), - dst_span: span, - src_span: val.span(), - }); - } - _ => (), + if let PipelineData::Empty = input { + return Err(ShellError::PipelineEmpty { dst_span: span }); } if rest.is_empty() {