fix: update process_metadata_outputs to handle serde_yaml::Value
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -169,7 +169,7 @@ impl MetaPlugin for DigestMetaPlugin {
|
|||||||
// Add the selected hash output
|
// Add the selected hash output
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||||
output_name,
|
output_name,
|
||||||
hash_value,
|
serde_yaml::Value::String(hash_value),
|
||||||
&self.outputs
|
&self.outputs
|
||||||
) {
|
) {
|
||||||
metadata.push(meta_data);
|
metadata.push(meta_data);
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ impl MetaPlugin for HostnameMetaPlugin {
|
|||||||
if hostname_enabled {
|
if hostname_enabled {
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||||
"hostname",
|
"hostname",
|
||||||
hostname_value,
|
serde_yaml::Value::String(hostname_value),
|
||||||
&self.outputs
|
&self.outputs
|
||||||
) {
|
) {
|
||||||
metadata.push(meta_data);
|
metadata.push(meta_data);
|
||||||
@@ -234,7 +234,7 @@ impl MetaPlugin for HostnameMetaPlugin {
|
|||||||
if hostname_full_enabled {
|
if hostname_full_enabled {
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||||
"hostname_full",
|
"hostname_full",
|
||||||
full_hostname.clone(),
|
serde_yaml::Value::String(full_hostname.clone()),
|
||||||
&self.outputs
|
&self.outputs
|
||||||
) {
|
) {
|
||||||
metadata.push(meta_data);
|
metadata.push(meta_data);
|
||||||
@@ -245,7 +245,7 @@ impl MetaPlugin for HostnameMetaPlugin {
|
|||||||
if hostname_short_enabled {
|
if hostname_short_enabled {
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||||
"hostname_short",
|
"hostname_short",
|
||||||
short_hostname,
|
serde_yaml::Value::String(short_hostname),
|
||||||
&self.outputs
|
&self.outputs
|
||||||
) {
|
) {
|
||||||
metadata.push(meta_data);
|
metadata.push(meta_data);
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ pub enum MetaPluginType {
|
|||||||
|
|
||||||
/// Central function to handle metadata output with name mapping
|
/// Central function to handle metadata output with name mapping
|
||||||
/// outputs: HashMap where key is internal name, value is either custom name or "false" to disable
|
/// outputs: HashMap where key is internal name, value is either custom name or "false" to disable
|
||||||
pub fn process_metadata_outputs(internal_name: &str, value: String, outputs: &std::collections::HashMap<String, serde_yaml::Value>) -> Option<MetaData> {
|
pub fn process_metadata_outputs(internal_name: &str, value: serde_yaml::Value, outputs: &std::collections::HashMap<String, serde_yaml::Value>) -> Option<MetaData> {
|
||||||
// Check if this output is disabled
|
// Check if this output is disabled
|
||||||
if let Some(mapping) = outputs.get(internal_name) {
|
if let Some(mapping) = outputs.get(internal_name) {
|
||||||
if let Some(false_val) = mapping.as_bool() {
|
if let Some(false_val) = mapping.as_bool() {
|
||||||
@@ -151,19 +151,40 @@ pub fn process_metadata_outputs(internal_name: &str, value: String, outputs: &st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(custom_name) = mapping.as_str() {
|
if let Some(custom_name) = mapping.as_str() {
|
||||||
debug!("META: Processing metadata: internal_name={}, custom_name={}, value={}", internal_name, custom_name, value);
|
// Convert the value to a string representation
|
||||||
|
let value_str = match &value {
|
||||||
|
serde_yaml::Value::Null => "null".to_string(),
|
||||||
|
serde_yaml::Value::Bool(b) => b.to_string(),
|
||||||
|
serde_yaml::Value::Number(n) => n.to_string(),
|
||||||
|
serde_yaml::Value::String(s) => s.clone(),
|
||||||
|
serde_yaml::Value::Sequence(_) => serde_yaml::to_string(&value).unwrap_or_else(|_| "".to_string()),
|
||||||
|
serde_yaml::Value::Mapping(_) => serde_yaml::to_string(&value).unwrap_or_else(|_| "".to_string()),
|
||||||
|
serde_yaml::Value::Tagged(_) => serde_yaml::to_string(&value).unwrap_or_else(|_| "".to_string()),
|
||||||
|
};
|
||||||
|
debug!("META: Processing metadata: internal_name={}, custom_name={}, value={}", internal_name, custom_name, value_str);
|
||||||
return Some(MetaData {
|
return Some(MetaData {
|
||||||
name: custom_name.to_string(),
|
name: custom_name.to_string(),
|
||||||
value,
|
value: value_str,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert the value to a string representation
|
||||||
|
let value_str = match &value {
|
||||||
|
serde_yaml::Value::Null => "null".to_string(),
|
||||||
|
serde_yaml::Value::Bool(b) => b.to_string(),
|
||||||
|
serde_yaml::Value::Number(n) => n.to_string(),
|
||||||
|
serde_yaml::Value::String(s) => s.clone(),
|
||||||
|
serde_yaml::Value::Sequence(_) => serde_yaml::to_string(&value).unwrap_or_else(|_| "".to_string()),
|
||||||
|
serde_yaml::Value::Mapping(_) => serde_yaml::to_string(&value).unwrap_or_else(|_| "".to_string()),
|
||||||
|
serde_yaml::Value::Tagged(_) => serde_yaml::to_string(&value).unwrap_or_else(|_| "".to_string()),
|
||||||
|
};
|
||||||
|
|
||||||
// Default: use internal name as output name
|
// Default: use internal name as output name
|
||||||
debug!("META: Processing metadata: name={}, value={}", internal_name, value);
|
debug!("META: Processing metadata: name={}, value={}", internal_name, value_str);
|
||||||
Some(MetaData {
|
Some(MetaData {
|
||||||
name: internal_name.to_string(),
|
name: internal_name.to_string(),
|
||||||
value,
|
value: value_str,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ impl TextMetaPlugin {
|
|||||||
// Use process_metadata_outputs to handle output mapping
|
// Use process_metadata_outputs to handle output mapping
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||||
"text",
|
"text",
|
||||||
text_value,
|
serde_yaml::Value::String(text_value),
|
||||||
self.base.outputs()
|
self.base.outputs()
|
||||||
) {
|
) {
|
||||||
metadata.push(meta_data);
|
metadata.push(meta_data);
|
||||||
@@ -217,7 +217,7 @@ impl TextMetaPlugin {
|
|||||||
|
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||||
"binary",
|
"binary",
|
||||||
binary_value,
|
serde_yaml::Value::String(binary_value),
|
||||||
self.base.outputs()
|
self.base.outputs()
|
||||||
) {
|
) {
|
||||||
metadata.push(meta_data);
|
metadata.push(meta_data);
|
||||||
@@ -277,7 +277,7 @@ impl TextMetaPlugin {
|
|||||||
if self.track_word_count {
|
if self.track_word_count {
|
||||||
crate::meta_plugin::process_metadata_outputs(
|
crate::meta_plugin::process_metadata_outputs(
|
||||||
"text_word_count",
|
"text_word_count",
|
||||||
self.word_count.to_string(),
|
serde_yaml::Value::String(self.word_count.to_string()),
|
||||||
self.base.outputs()
|
self.base.outputs()
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -290,7 +290,7 @@ impl TextMetaPlugin {
|
|||||||
if self.track_line_count {
|
if self.track_line_count {
|
||||||
crate::meta_plugin::process_metadata_outputs(
|
crate::meta_plugin::process_metadata_outputs(
|
||||||
"text_line_count",
|
"text_line_count",
|
||||||
self.line_count.to_string(),
|
serde_yaml::Value::String(self.line_count.to_string()),
|
||||||
self.base.outputs()
|
self.base.outputs()
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -303,7 +303,7 @@ impl TextMetaPlugin {
|
|||||||
if self.output_line_max_len && self.line_count_for_stats > 0 {
|
if self.output_line_max_len && self.line_count_for_stats > 0 {
|
||||||
crate::meta_plugin::process_metadata_outputs(
|
crate::meta_plugin::process_metadata_outputs(
|
||||||
"text_line_max_len",
|
"text_line_max_len",
|
||||||
self.max_line_length.to_string(),
|
serde_yaml::Value::String(self.max_line_length.to_string()),
|
||||||
self.base.outputs()
|
self.base.outputs()
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -319,7 +319,7 @@ impl TextMetaPlugin {
|
|||||||
let mean_len_int = mean_len.round() as usize;
|
let mean_len_int = mean_len.round() as usize;
|
||||||
crate::meta_plugin::process_metadata_outputs(
|
crate::meta_plugin::process_metadata_outputs(
|
||||||
"text_line_mean_len",
|
"text_line_mean_len",
|
||||||
mean_len_int.to_string(),
|
serde_yaml::Value::String(mean_len_int.to_string()),
|
||||||
self.base.outputs()
|
self.base.outputs()
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -342,7 +342,7 @@ impl TextMetaPlugin {
|
|||||||
|
|
||||||
return crate::meta_plugin::process_metadata_outputs(
|
return crate::meta_plugin::process_metadata_outputs(
|
||||||
"text_line_median_len",
|
"text_line_median_len",
|
||||||
median_len.to_string(),
|
serde_yaml::Value::String(median_len.to_string()),
|
||||||
self.base.outputs()
|
self.base.outputs()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user