Skip to content

router: apply input routes with a single input and output - #12596

Merged
edsiper merged 2 commits into
masterfrom
fix/router-single-pair-routes
Oct 17, 2026
Merged

edsiper merged 2 commits into
masterfrom
fix/router-single-pair-routes

Conversation

@edsiper

@edsiper edsiper commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Problem

With exactly one input and one output, flb_router_io_set() connects the two
directly and returns before applying the routes of the configuration. The
input gets no direct routes, so route conditions are never evaluated: records
that match no route still reach the output.

pipeline:
  inputs:
    - name: dummy
      dummy: '{"topic":"topic2"}'
      routes:
        logs:
          - name: topic1
            condition:
              op: and
              rules:
                - field: $topic
                  op: eq
                  value: topic1
            to:
              outputs:
                - out1
  outputs:
    - name: stdout
      alias: out1

Before this change the record is printed. After it, it is not, the same as
when the pipeline has more inputs or outputs.

Change

Take the 1:1 shortcut only when no input has routes. Inputs with routes go
through the regular setup and the router configuration.

Testing

New integration tests in tests/integration/scenarios/out_stdout for a
matching and a non-matching route with one input and one output. Both fail on
master and pass with this change.

ctest --test-dir build -R 'rout|condition'          # 8/8 passed
pytest scenarios/out_stdout                          # 16 passed
VALGRIND=1 VALGRIND_STRICT=1 pytest scenarios/out_stdout -n 4   # 16 passed, no errors

Summary by CodeRabbit

  • Bug Fixes
    • Conditional routes are now applied when a configuration has one input and one output, preventing records from being sent unconditionally. Matching records are delivered, while records that do not meet the route condition are not sent.

With one input and one output, the router connected them directly and
returned before applying the routes of the configuration. Route
conditions were never evaluated, so records matching no route still
reached the output. Take the shortcut only when no input has routes.

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
…output

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@edsiper
edsiper requested a review from cosmo0920 as a code owner October 17, 2026 20:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T20:29:58.475743Z ea76030 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 53988613-cbb0-4f95-bc6b-ae21c137f97a
📥 Commits

Reviewing files that changed from the base of the PR and between f5374f7 and ea76030.

📒 Files selected for processing: 4
  • src/flb_router.c
  • tests/integration/scenarios/out_stdout/config/out_stdout_single_pair_conditional_match.yaml
  • tests/integration/scenarios/out_stdout/config/out_stdout_single_pair_conditional_miss.yaml
  • tests/integration/scenarios/out_stdout/tests/test_out_stdout_001.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The router now uses the single-input/one-output shortcut only when no input routes are configured. Integration tests check conditional routes with matching and unmatched records.

Changes: Conditional routing

Layer / File(s) Summary
Route application and validation
src/flb_router.c, tests/integration/scenarios/out_stdout/config/out_stdout_single_pair_conditional_*.yaml, tests/integration/scenarios/out_stdout/tests/test_out_stdout_001.py
The router applies configured input routes for single-input/one-output pairs. Integration tests check that a matching route delivers a record and an unmatched route does not.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to ea760

The routing change has tests for both matching and unmatched records, with no identified issue preventing merge after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: applying input routes when one input and one output are configured.
Docstring Coverage Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (2 skipped: 2 u…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@edsiper
edsiper merged commit d843bd4 into master Oct 17, 2026
64 checks passed
@edsiper
edsiper deleted the fix/router-single-pair-routes branch October 17, 2026 21:06
@edsiper edsiper added this to the Fluent Bit v5.1.5 milestone Oct 17, 2026

This branch was successfully deployed

1 active deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant