Skip to content

fix(pipeline): if/then/else evaluates against the current record inside for_each - #408

Open
medcl wants to merge 1 commit into
mainfrom
if-else-record-context
Open

fix(pipeline): if/then/else evaluates against the current record inside for_each#408
medcl wants to merge 1 commit into
mainfrom
if-else-record-context

Conversation

@medcl

@medcl medcl commented Aug 26, 2026

Copy link
Copy Markdown
Member

Problem

The if/then/else processor checked its condition against the pipeline Context (parameters), which carries no per-record data. Inside per-record sub-chains (e.g. for_each), every if-condition silently evaluated against an empty value map — conditional routing never fired at runtime.

Fix

IfThenElseProcessor.Process now evaluates the condition against the bound current record when one exists (pipeline.CurrentRecord); *event.Event satisfies conditions.ValuesMap via its GetValue. 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
  • Verified via LogPilot parsing-chain test replay: a {"if": {"contains": {"file.path": "nginx"}}, "then": [...]} entry now takes the then-branch inside for_each (previously always fell through)

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant