From f32a2b76acf811e11018b3b9feea9518442d9a43 Mon Sep 17 00:00:00 2001 From: Pavlos Rontidis Date: Fri, 16 Aug 2024 14:32:01 -0400 Subject: [PATCH] more review points --- src/internal_events/reduce.rs | 5 ++++- src/transforms/reduce/transform.rs | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/internal_events/reduce.rs b/src/internal_events/reduce.rs index 74aace0925698..b9887aaf54bb7 100644 --- a/src/internal_events/reduce.rs +++ b/src/internal_events/reduce.rs @@ -1,6 +1,7 @@ use metrics::counter; use vector_lib::internal_event::{error_stage, error_type, InternalEvent}; use vrl::path::PathParseError; +use vrl::value::KeyString; #[derive(Debug)] pub struct ReduceStaleEventFlushed; @@ -14,12 +15,14 @@ impl InternalEvent for ReduceStaleEventFlushed { #[derive(Debug)] pub struct ReduceAddEventError { pub error: PathParseError, + pub path: KeyString, } impl InternalEvent for ReduceAddEventError { fn emit(self) { error!( - message = "Event could not be reduced.", + message = "Event field could not be reduced.", + path = ?self.path, error = ?self.error, error_type = error_type::CONDITION_FAILED, stage = error_stage::PROCESSING, diff --git a/src/transforms/reduce/transform.rs b/src/transforms/reduce/transform.rs index d630611ae53dd..f3e4e8050054f 100644 --- a/src/transforms/reduce/transform.rs +++ b/src/transforms/reduce/transform.rs @@ -77,16 +77,22 @@ impl ReduceState { } if let Some(fields_iter) = e.all_event_fields_skip_array_elements() { - for (mut path, value) in fields_iter { - // TODO: Addressed in issue 21077. - if path.contains("\\.") { - path = quote_invalid_paths(&path).into(); - } + for (path, value) in fields_iter { + // TODO: This can be removed once issue 21077 is resolved. + // Technically we need to quote any special characters (like `-` or `*` or ` `). + let parsable_path = if path.contains("\\.") { + quote_invalid_paths(&path).into() + } else { + path.clone() + }; // This should not return an error, unless there is a bug in the event fields iterator. - let parsed_path = match parse_target_path(&path) { + let parsed_path = match parse_target_path(&parsable_path) { Ok(path) => path, - Err(error) => return emit!(ReduceAddEventError { error }), + Err(error) => { + emit!(ReduceAddEventError { error, path }); + continue; + } }; if is_covered_by_strategy(&parsed_path, strategies) { continue;