Skip to content

backport: env: add bash-style default value operator :-#11806

Merged
cosmo0920 merged 2 commits into
fluent:4.2from
benjaminmueggenburg-serato:4.2
May 18, 2026
Merged

backport: env: add bash-style default value operator :-#11806
cosmo0920 merged 2 commits into
fluent:4.2from
benjaminmueggenburg-serato:4.2

Conversation

@benjaminmueggenburg-serato
Copy link
Copy Markdown
Contributor

@benjaminmueggenburg-serato benjaminmueggenburg-serato commented May 14, 2026

Backport to 4.2 of #11787

The below description is a copy from that PR, however, test output has been reran on this 4.2 backport.


Adds the familiar bash-style default value operator :-.
Now inside configuration files ${VALUE:-default} will resolve to default if VALUE variable is not set (os or locally) or is empty ''.

Addresses #5517

Configuration example

Expand
[SERVICE]
    flush        1
    log_level    info
[INPUT]
    name         cpu
    tag          cpu.local
    interval_sec 1
[FILTER]
    name         record_modifier
    match        *
    record       env_check ${TEST_ZONE:-default-region}
[OUTPUT]
    name         stdout
    match        *
    format       json_lines

Checklist (maintainers)

  • Debug log output from testing the change
Debug / stdout

Unset TEST_ZONE

{"date":1778797137.454888,"cpu_p":0.3,"user_p":0.2,"system_p":0.1,"cpu0.p_cpu":0.0,"cpu0.p_user":0.0,"cpu0.p_system":0.0,"cpu1.p_cpu":0.0,"cpu1.p_user":0.0,"cpu1.p_system":0.0,"env_check":"default-region"}
{"date":1778797138.457873,"cpu_p":0.0,"user_p":0.0,"system_p":0.0,"cpu0.p_cpu":0.0,"cpu0.p_user":0.0,"cpu0.p_system":0.0,"cpu1.p_cpu":0.0,"cpu1.p_user":0.0,"cpu1.p_system":0.0,"env_check":"default-region"}

Set TEST_ZONE=eu-east-1:

{"date":1778797312.487864,"cpu_p":0.4,"user_p":0.3,"system_p":0.1,"cpu0.p_cpu":0.0,"cpu0.p_user":0.0,"cpu0.p_system":0.0,"cpu1.p_cpu":0.0,"cpu1.p_user":0.0,"cpu1.p_system":0.0,"env_check":"us-east-1"}
{"date":1778797313.490645,"cpu_p":0.0,"user_p":0.0,"system_p":0.0,"cpu0.p_cpu":0.0,"cpu0.p_user":0.0,"cpu0.p_system":0.0,"cpu1.p_cpu":0.0,"cpu1.p_user":0.0,"cpu1.p_system":0.0,"env_check":"us-east-1"}

Unit tests

$ ctest --test-dir build -L internal --output-on-failure
[...]
      Start 39: flb-it-env
39/77 Test #39: flb-it-env .......................   Passed    0.01 sec
[...]

100% tests passed, 0 tests failed out of 77

Label Time Summary:
internal    =  84.93 sec*proc (77 tests)

Total Test time (real) =  85.01 sec

  • Attached Valgrind output that shows no leaks or memory corruption
Valgrind summary / log tail

Command:

$ valgrind --leak-check=full --error-exitcode=1 ./build/bin/flb-it-env

Valgrind tail:

==1== Memcheck, a memory error detector
==1== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==1== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info
==1== Command: ./bin/flb-it-env
==1== 
Test translate_long_env...                      ==1== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test expand_default_hyphen...                   ==1== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test expand_empty_default...                    ==1== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test expand_default_hyphen_from_os...           ==1== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
SUCCESS: All unit tests have passed.
==1== 
==1== HEAP SUMMARY:
==1==     in use at exit: 0 bytes in 0 blocks
==1==   total heap usage: 3,697 allocs, 3,697 frees, 474,156 bytes allocated
==1== 
==1== All heap blocks were freed -- no leaks are possible
==1== 
==1== For lists of detected and suppressed errors, rerun with: -s
==1== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

fluent/fluent-bit-docs#2568

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Signed-off-by: benjaminmueggenburg-serato <benjamin.mueggenburg@serato.com>
Signed-off-by: benjaminmueggenburg-serato <benjamin.mueggenburg@serato.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4bb59916-17e5-46f2-894e-b299ce13baaf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@cosmo0920 cosmo0920 merged commit 490ac0a into fluent:4.2 May 18, 2026
26 checks passed
@cosmo0920 cosmo0920 added this to the Fluent Bit v4.2.5 milestone May 29, 2026
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.

2 participants