Repository navigation
Description
Bug Report
Describe the bug
flb_upstream_ha_from_file() (src/flb_upstream_ha.c) handles YAML upstream files incorrectly in two ways.
-
Only the last group is used, and the others leak. The YAML branch loops over every entry in
upstream_serversand assigns each new group to the sameupspointer:mk_list_foreach(head, &cf->upstream_servers) { ... ups = flb_upstream_ha_create(tmp); ... }
If the file defines more than one group, the function returns only the last group, and the earlier groups are never destroyed. No error or warning is logged. If node creation fails in a later group, the error path destroys only the current group, so the earlier groups leak there too.
-
A YAML file without groups uses an uninitialized pointer.
upsis declared without an initializer (struct flb_upstream_ha *ups;). If the YAML file has noupstream_serversentries, the loop body never runs,cstays0, and thec == 0path callsflb_upstream_ha_destroy(ups)on that uninitialized pointer. The same path is reached if the file isn't recognized as either classic or YAML format, for example a YAML file on a build withoutFLB_HAVE_LIBYAML.
Both were found by reading the code on master; I haven't run them under a debugger or Valgrind. The YAML branch was added in d2569b2 (first released in v3.2.0) and is unchanged since.
The classic format isn't affected: it reads exactly one [UPSTREAM] section, and ups is always set before the c == 0 check.
To Reproduce
Issue 1: upstream file upstream.yaml:
upstream_servers:
- name: group-a
nodes:
- name: a-1
host: 127.0.0.1
port: 24224
- name: group-b
nodes:
- name: b-1
host: 127.0.0.1
port: 24225Main configuration:
pipeline:
inputs:
- name: dummy
tag: test
outputs:
- name: forward
match: '*'
upstream: upstream.yamlAll records go to port 24225 (group-b). group-a is ignored without a message, and running under Valgrind should report the group-a allocations as leaked.
Issue 2: an upstream file that parses as YAML but has no upstream_servers entries, for example:
service:
log_level: infoExpected behavior
- A file with more than one group either fails at startup with a clear error or documents and logs which group is used, without leaking the others.
upsis initialized toNULL, and thec == 0path only destroys it when it's set.
Your Environment
- Version used: master (
27d56241b); YAML branch present since v3.2.0 - Configuration: see above
- Filters and plugins:
out_forwardandout_esboth load upstream files throughflb_upstream_ha_from_file()
Additional context
The YAML upstream servers page in fluent-bit-docs showed two groups in one file, which led readers to configure files that silently lose a group. A docs fix is in progress.
Activity
eschabell commentedon Nov 14, 2026
Docs fix: fluent/fluent-bit-docs#2843
edsiper commentedon Nov 20, 2026
@codex review
chatgpt-codex-connector commentedon Nov 20, 2026
Summary
01025c5(upstream_ha: reject ambiguous YAML groups) with a DCO sign-off and created the follow-up pull request metadata titled “upstream_ha: reject ambiguous YAML groups safely.”Testing
cmake -S . -B build -DFLB_TESTS_RUNTIME=On -DFLB_TESTS_INTERNAL=Oncmake --build build -j8 --target flb-it-upstream_hactest --test-dir build -R '^flb-it-upstream_ha$' --output-on-failurevalgrind --leak-check=full --error-exitcode=1 ./build/bin/flb-it-upstream_ha— all three tests passed, all allocations were freed, and Valgrind reported zero errors.cmake --build build -j8 --target fluent-bit-binforwardoutput initialization using the multiple-group fixture — startup rejected the file withexpected exactly one upstream group, and Fluent Bit exited with status255.git diff --checkpython .github/scripts/commit_prefix_check.py— could not run because GitPython is unavailable; installation withpython3 -m pip install gitpythonwas blocked by the environment’s package-index proxy returning HTTP 403.View task →