From d37893cca0aac573e623ca0e25a5e7ed1828b02f Mon Sep 17 00:00:00 2001 From: Marika Chlebowska Date: Fri, 24 Nov 2023 14:45:01 +0100 Subject: [PATCH] Add more descriptive error message when passing list to from_csv (#10962) # Description Added statement catching early List passed to CSV and printing more helpful error message. This fixes #10081. Similar message might be useful for other from_* calls but I'm not sure if there aren't any converters accepting List as input. # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/formats/from/csv.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/nu-command/src/formats/from/csv.rs b/crates/nu-command/src/formats/from/csv.rs index 5072914f2..679d2d1e3 100644 --- a/crates/nu-command/src/formats/from/csv.rs +++ b/crates/nu-command/src/formats/from/csv.rs @@ -129,6 +129,13 @@ fn from_csv( input: PipelineData, ) -> Result { let name = call.head; + if let PipelineData::Value(Value::List { .. }, _) = input { + return Err(ShellError::TypeMismatch { + err_message: "received list stream, did you forget to open file with --raw flag?" + .into(), + span: name, + }); + } let separator = match call.get_flag::(engine_state, stack, "separator")? { Some(sep) => {