fix: prevent emitting disabled metadata outputs as null
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -533,20 +533,24 @@ impl MetaPlugin for TextMetaPlugin {
|
|||||||
self.buffer = None; // Drop the buffer
|
self.buffer = None; // Drop the buffer
|
||||||
self.is_finalized = true;
|
self.is_finalized = true;
|
||||||
// Set all text-related outputs to None since content is binary
|
// Set all text-related outputs to None since content is binary
|
||||||
|
// Only include outputs that are enabled in the configuration
|
||||||
let text_outputs = vec![
|
let text_outputs = vec![
|
||||||
"text_word_count",
|
("text_word_count", self.track_word_count),
|
||||||
"text_line_count",
|
("text_line_count", self.track_line_count),
|
||||||
"text_line_max_len",
|
("text_line_max_len", self.output_line_max_len),
|
||||||
"text_line_mean_len",
|
("text_line_mean_len", self.output_line_mean_len),
|
||||||
"text_line_median_len",
|
("text_line_median_len", self.output_line_median_len),
|
||||||
];
|
];
|
||||||
for output_name in text_outputs {
|
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
for (output_name, is_enabled) in text_outputs {
|
||||||
output_name,
|
if is_enabled {
|
||||||
serde_yaml::Value::Null,
|
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||||
self.base.outputs()
|
output_name,
|
||||||
) {
|
serde_yaml::Value::Null,
|
||||||
metadata.push(meta_data);
|
self.base.outputs()
|
||||||
|
) {
|
||||||
|
metadata.push(meta_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return MetaPluginResponse {
|
return MetaPluginResponse {
|
||||||
@@ -564,26 +568,9 @@ impl MetaPlugin for TextMetaPlugin {
|
|||||||
metadata.extend(word_line_metadata);
|
metadata.extend(word_line_metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set disabled outputs to None
|
// Only include outputs that are enabled in the configuration
|
||||||
let outputs_to_check = vec![
|
// Disabled outputs should not be emitted at all (not even as null)
|
||||||
("text_word_count", self.track_word_count),
|
// So we don't need to add anything for disabled outputs
|
||||||
("text_line_count", self.track_line_count),
|
|
||||||
("text_line_max_len", self.output_line_max_len),
|
|
||||||
("text_line_mean_len", self.output_line_mean_len),
|
|
||||||
("text_line_median_len", self.output_line_median_len),
|
|
||||||
];
|
|
||||||
|
|
||||||
for (output_name, is_enabled) in outputs_to_check {
|
|
||||||
if !is_enabled {
|
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
|
||||||
output_name,
|
|
||||||
serde_yaml::Value::Null,
|
|
||||||
self.base.outputs()
|
|
||||||
) {
|
|
||||||
metadata.push(meta_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drop the buffer since we're done with it
|
// Drop the buffer since we're done with it
|
||||||
self.buffer = None;
|
self.buffer = None;
|
||||||
|
|||||||
Reference in New Issue
Block a user