fix(pipeline): if/then/else evaluates against the current record inside for_each - #408
Open
medcl wants to merge 1 commit into
Open
fix(pipeline): if/then/else evaluates against the current record inside for_each#408medcl wants to merge 1 commit into
medcl wants to merge 1 commit into
Conversation
…de per-record sub-chains The condition was checked against the pipeline Context (parameters), which carries no per-record data — inside for_each sub-chains every if-condition silently evaluated against an empty map. Evaluate against the bound record when one exists (event.Event implements conditions.ValuesMap), falling back to the context for pipeline-level usage. Enables conditional routing in parsing chains.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
if/then/elseprocessor checked its condition against the pipelineContext(parameters), which carries no per-record data. Inside per-record sub-chains (e.g.for_each), everyif-condition silently evaluated against an empty value map — conditional routing never fired at runtime.Fix
IfThenElseProcessor.Processnow evaluates the condition against the bound current record when one exists (pipeline.CurrentRecord);*event.Eventsatisfiesconditions.ValuesMapvia itsGetValue. Falls back to the context when no record is bound (pipeline-level usage unchanged).Enables conditional routing (e.g. on promoted context fields like
file.path/host.name) inside parsing chains.Testing
go test ./core/pipeline/passes{"if": {"contains": {"file.path": "nginx"}}, "then": [...]}entry now takes the then-branch insidefor_each(previously always fell through)