From 940dc2efd71526f1eaea616036cce33b23a43a84 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 27 Aug 2025 22:53:01 -0300 Subject: [PATCH] fix: handle null values in YAML output conversion Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) --- src/modes/generate_config.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/modes/generate_config.rs b/src/modes/generate_config.rs index f362022..826e2c1 100644 --- a/src/modes/generate_config.rs +++ b/src/modes/generate_config.rs @@ -161,11 +161,18 @@ fn convert_outputs_to_string_map( ) -> std::collections::HashMap { let mut result = std::collections::HashMap::new(); for (key, value) in outputs { - if let Some(str_value) = value.as_str() { - result.insert(key.clone(), str_value.to_string()); - } else { - // Convert non-string values to their YAML string representation - result.insert(key.clone(), serde_yaml::to_string(value).unwrap_or_default()); + match value { + serde_yaml::Value::Null => { + // For null, we want to output "null" as a string + result.insert(key.clone(), "null".to_string()); + } + serde_yaml::Value::String(s) => { + result.insert(key.clone(), s.clone()); + } + _ => { + // Convert other values to their YAML string representation + result.insert(key.clone(), serde_yaml::to_string(value).unwrap_or_default()); + } } } result