fix: handle null values in YAML output conversion

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-27 22:53:01 -03:00
parent a53591d28e
commit 940dc2efd7

View File

@@ -161,12 +161,19 @@ fn convert_outputs_to_string_map(
) -> std::collections::HashMap<String, String> {
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
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
}