From 9ae3715b2b3e3fdacbfc6417cacf0c910c3d1fa8 Mon Sep 17 00:00:00 2001 From: pashifika Date: Wed, 11 Sep 2024 22:44:48 +0900 Subject: [PATCH] fix: Specified attribute not found in the item error. (#261) Signed-off-by: pashifika --- src/data.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/data.rs b/src/data.rs index 7d9702c..c91d78e 100644 --- a/src/data.rs +++ b/src/data.rs @@ -1121,7 +1121,10 @@ fn convert_item_to_csv_line( if keys_only { } else if let Some(attrs) = attributes_to_append { for attr /* String */ in attrs { - let attrval: &AttributeValue = item.iter().find(|x| x.0 == attr).expect("Specified attribute not found in the item.").1; + let attrval: &AttributeValue = match item.iter().find(|x| x.0 == attr) { + None => &AttributeValue::Null(true), + Some(x) => x.1 + }; line.push(','); // NOTE: If special handling for complex data type is needed: `if let Some(_) = attrval.m {...` line.push_str(&attrval_to_jsonval(attrval).to_string());