Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
597 commits
Select commit Hold shift + click to select a range
ab1d2d0
tests: internal: router_config: extend test for conditional logs
edsiper Oct 20, 2025
f537b1d
wip
edsiper Oct 20, 2025
26d0cba
wip
edsiper Oct 21, 2025
2465034
wip
edsiper Oct 21, 2025
c4a017b
wip
edsiper Oct 21, 2025
2a43642
wip
edsiper Oct 21, 2025
7b6e788
router: use cfl_list for router path
edsiper Oct 27, 2025
2c38bb2
input_log: code cleanup and fix types for linked lists
edsiper Oct 27, 2025
68b7efb
input: fix data type for routes_direct
edsiper Oct 27, 2025
fa8e8b3
router_config: fix data type for linked list
edsiper Oct 27, 2025
9aa07ac
task: fix data type for linked list
edsiper Oct 27, 2025
aa70b3e
input_log: preserve non-conditional routes when conditional routing i…
edsiper Oct 27, 2025
07729df
input_log: handle deferred chunk creation in threaded inputs with con…
edsiper Oct 27, 2025
380c159
input: include cfl header
edsiper Oct 27, 2025
e3eeb0b
router: use cfl_list intead of mk_list
edsiper Oct 27, 2025
995dd12
input: fix llist initialization
edsiper Oct 27, 2025
6bab255
sosreport: fix list iterator api
edsiper Oct 27, 2025
459cb8b
tests: internal: router_config: fix lists API
edsiper Oct 27, 2025
98009ae
input_chunk: expose flb_input_chunk_get_real_size()
edsiper Oct 28, 2025
32ebcda
tests: internal: input_chunk: remove unused code
edsiper Oct 28, 2025
f9c1fb7
input_log: implement conditional routing with non-conditional route p…
edsiper Oct 28, 2025
7931211
input_log: recompute per-output storage accounting
edsiper Oct 28, 2025
aca8fff
input_log: remove debug messages and cleanup
edsiper Oct 30, 2025
83662c4
routes_mask: correct memcmp byte count in flb_routes_mask_is_empty
edsiper Oct 30, 2025
a8045b9
router_config: remove debug message
edsiper Oct 30, 2025
3cc7af0
task: remove routes_mask check from direct-route branch
edsiper Oct 30, 2025
f879a93
tests: internal: aws_credentials_sts: fix unit test (timestamps)
cosmo0920 Oct 30, 2025
8ff0949
workflows: bump actions/upload-artifact from 4 to 5
dependabot[bot] Oct 27, 2025
93d3fb3
workflows: bump actions/download-artifact from 5 to 6
dependabot[bot] Oct 27, 2025
f5597d8
router_condition: Fix unconditional route check in routing
cosmo0920 Oct 31, 2025
652b3fb
out_vivo_exporter: change API endpoints to /api/v1/
edsiper Oct 4, 2025
97183b1
out_vivo_exporter: add groups support
edsiper Oct 6, 2025
2baf131
out_vivo_exporter: fix regression on buffer check
edsiper Nov 1, 2025
439b5d4
conditionals: add context support for routing conditions
edsiper Oct 31, 2025
32d119a
router: add context support for conditional routing
edsiper Oct 31, 2025
6b4604c
tests: internal: router_config: add context routing tests
edsiper Oct 31, 2025
7c9bf65
router: implement context variable resolution
edsiper Oct 31, 2025
d843a0c
input_log: add context extraction from log records
edsiper Oct 31, 2025
f176701
log_event_decoder: add context extraction helpers
edsiper Oct 31, 2025
a7d0510
task: pass context to router condition evaluation
edsiper Oct 31, 2025
03d3c2e
processor_content_modifier: skip GROUP_START markers during metadata/…
edsiper Oct 31, 2025
1f5e2bc
input_log: improve context extraction and routing
edsiper Oct 31, 2025
6b8fbdd
lib: add context support API for routing
edsiper Oct 31, 2025
2d07323
tests: runtime: in_opentelemetry_routing: add context tests
edsiper Oct 31, 2025
e97f611
input_log: fix context handling edge cases
edsiper Oct 31, 2025
ee09f62
tests: internal: router_config: fix test assertions
edsiper Oct 31, 2025
34c08fe
tests: internal: conditional_routing: add context tests
edsiper Oct 31, 2025
22bcf50
tests: data: add context routing configuration examples
edsiper Oct 31, 2025
6a80c78
tests: runtime: in_opentelemetry_routing: enhance tests
edsiper Oct 31, 2025
1256bf8
lib: use flb_compat.h instead of unistd.h (Windows issue)
edsiper Nov 1, 2025
71fd847
input_log: fix variable declaration
edsiper Nov 1, 2025
ae04ea2
conditionals: fix NULL record handling in flb_condition_evaluate
edsiper Nov 1, 2025
311d930
tests: internal: conditionals: NULL record should fail condition
edsiper Nov 1, 2025
7b87bbb
log_event_decoder: add tests for group marker skipping with corrupted…
edsiper Nov 1, 2025
0e6513f
tests: internal: log_event_decoder: add comprehensive tests for group…
edsiper Nov 1, 2025
668358c
log_event_decoder: improve robustness for invalid group markers
edsiper Nov 1, 2025
7a1083c
snap: Bump up core20 from core18
cosmo0920 Oct 24, 2025
eb9744b
snap: Install /usr prefix
cosmo0920 Oct 24, 2025
8b7cfba
snap: Follow the layout change
cosmo0920 Oct 27, 2025
2f7791e
doc-reports: add cncf audit report
DavidKorczynski Oct 20, 2025
f98fede
lib: chunkio: upgrade to v1.5.4
edsiper Nov 3, 2025
c56dc3d
input_chunk: extend chunk layer to support routing information
edsiper Nov 3, 2025
5852c0e
input_log: write direct routes when creating chunks
edsiper Nov 3, 2025
8185700
task: restores direct routes from chunk metadata
edsiper Nov 3, 2025
139bd2b
tests: internal: add new input_chunk_routes.c
edsiper Nov 3, 2025
2e62f11
doc: update CHUNKS.md with extended layer info
edsiper Nov 4, 2025
c701590
input_chunk: add direct route labels and plugin name support
edsiper Nov 4, 2025
58a0f16
input_log: store labels and plugin names in chunk metadata
edsiper Nov 4, 2025
80e682d
task: restore direct routes using label-based matching
edsiper Nov 4, 2025
babbf92
tests: internal: add direct route persistence tests
edsiper Nov 4, 2025
5a15b12
tests: internal: input_chunk_route: add missing cmt init
edsiper Nov 4, 2025
fb24892
tests: internal: input_chunk_route: simplify cleanup logic
edsiper Nov 4, 2025
ed06c31
workflows: bump helm/kind-action from 1.12.0 to 1.13.0
dependabot[bot] Nov 4, 2025
8546892
CODEOWNERS: update AWS maintainers and cleanup
edsiper Nov 4, 2025
d8265db
dockerfile: removed unused DLLs from image for Windows Containers.
mabrarov Apr 8, 2025
72506e0
dockerfile: fixed description of "MSVS_VERSION" build-arg.
mabrarov Jun 22, 2025
ce81b97
dockerfile: upgrade of vcpkg to solve msys2 package installation issu…
mabrarov Nov 4, 2025
c7a707e
ci: sanity check of the built Windows docker image.
mabrarov Nov 4, 2025
7eab11a
plugins: kafka: fix cmake cross compile error
ThomasDevoogdt Nov 16, 2024
cc15e1b
build: Implement strict pointer types option
cosmo0920 Oct 21, 2025
8579d63
workflows: Add CI task for strict pointer types
cosmo0920 Oct 21, 2025
baa0153
tls: openssl: Implement certificates" thumbprint handlings
cosmo0920 Oct 10, 2025
3d3db60
output: Handle to load certificates with their thumbprints
cosmo0920 Oct 10, 2025
a2917b8
in_syslog: Handle octent_counting
cosmo0920 Oct 17, 2025
5bf9544
in_syslog: Add test cases for octet counting
cosmo0920 Oct 17, 2025
4789437
in_syslog: Include a header explicitly
cosmo0920 Oct 17, 2025
16e2dd8
in_syslog: tests: Split declaration and applying values
cosmo0920 Oct 20, 2025
9f8c816
in_syslog: tests: Use format instead of frame
cosmo0920 Oct 20, 2025
814b848
wasm: Plug wasm heap leakages
cosmo0920 Oct 27, 2025
b67db02
scheduler: engine: Plug macOS abort on dry-run
cosmo0920 Nov 4, 2025
ef58c53
output_thread: Validate a magic for cleaning up correctly on macOS
cosmo0920 Nov 4, 2025
be2f2be
scheduler: Use a correct type on a member
cosmo0920 Nov 5, 2025
7ce0d16
router: add router context structure and move routing state
edsiper Nov 4, 2025
0fc19d1
router: implement router context creation and lifecycle
edsiper Nov 4, 2025
b361654
routes_mask: migrate API to use router context instead of config
edsiper Nov 4, 2025
0adf3e4
config: integrate router context creation and destruction
edsiper Nov 4, 2025
350a944
engine: publish routing metrics on log batch flush and drop
edsiper Nov 4, 2025
b891248
input_chunk: update routing mask operations to use router context
edsiper Nov 4, 2025
53ac9f8
input_log: update routing mask operations to use router context
edsiper Nov 4, 2025
db86f1b
metrics_exporter: merge router metrics into /metrics output
edsiper Nov 4, 2025
d05826f
in_storage_backlog: update routing mask operations to use router context
edsiper Nov 4, 2025
2d3ce50
task: update routing mask checks to use router context
edsiper Nov 4, 2025
b0cdb17
tests: internal: routing: update routing tests to use router context
edsiper Nov 4, 2025
f73850f
input_chunk: small cleanup
edsiper Nov 4, 2025
6c487f0
router: remove unnecessary function
edsiper Nov 4, 2025
a62268e
tests: internal: input_chunk_routes: fix compiler warnings
edsiper Nov 4, 2025
3eb6c5b
tests: internal: fuzzers: aws_credentials_fuzzer: fix incorrect lengt…
edsiper Nov 4, 2025
de81352
config: release kernel context on router creation error
edsiper Nov 5, 2025
9fbf2e1
bin: destroy cf opts on failure
edsiper Nov 6, 2025
02c9e9f
config: release http resources on exit
edsiper Nov 6, 2025
05c8c3a
out_s3: Add a NULL check for plugging SEGV on dry_run
cosmo0920 Nov 6, 2025
7970be4
build: Add workdir option for the default registration of Windows ser…
cosmo0920 Nov 7, 2025
cddd506
packaging: add missing SASL dependencies for Rocky/AlmaLinux
patrick-stephens Nov 7, 2025
a4c158d
thread_storage: Use pthread_once to ensure FLB_TLS_INIT only calls pt…
ThomasBrady Oct 31, 2025
c26a2d1
out_opensearch: release aws signature a retry or error happens
edsiper Nov 8, 2025
00baa18
router: for direct routes improve the handling of input instance source
edsiper Nov 9, 2025
db274a3
tests: internal: routing: extend tests for routing paths
edsiper Nov 9, 2025
b63bcf4
motd: add 4.2 banner
edsiper Nov 9, 2025
a25b789
version: reflect organization and status change
edsiper Nov 9, 2025
6552b7a
docs: README: reflect organization and status change
edsiper Nov 9, 2025
e971292
dockerfiles: README: reflect organization and status change
edsiper Nov 9, 2025
a8d39bb
out_http: Plug a NULL dereference
cosmo0920 Oct 17, 2025
b6fcaab
out_http: added PUT support (#10882)
nicknezis Nov 9, 2025
34b1f76
task: account metrics for dropped events
edsiper Nov 9, 2025
aea80e6
input_log: account routing metrics for unmatched/dropped logs
edsiper Nov 9, 2025
7612a09
in_tail: Implement long ling truncation
cosmo0920 Nov 10, 2025
e9f63e6
tests: runtime: in_tail: Add test cases for long line truncations
cosmo0920 Nov 10, 2025
9ed44f0
in_systemd: add explicit restarts for the journal data cursor
edsiper Oct 28, 2025
d17e943
packaging: add -L flag to curl for redirect support The packages.flu…
sakshitposting-irl Nov 8, 2025
3d6f0bc
config: Add dead letter queue related config
cosmo0920 Oct 8, 2025
6b74d58
config: storage: Implement dlq for filesystem chunks
cosmo0920 Oct 8, 2025
81ee67c
engine: Add a capability to handle dead letter queue for preserving i…
cosmo0920 Oct 8, 2025
5ac5b9e
storage: Use correct visibility of struct flb_input_instance
cosmo0920 Oct 8, 2025
90d5ad0
storage: tests: internal: Add DLQ internal tests
cosmo0920 Oct 8, 2025
d8878be
storage: tests: internal: Make to be able to compile on Windows
cosmo0920 Oct 9, 2025
e183f81
storage: tests: internal: Fix a compilation error on CentOS 7
cosmo0920 Oct 9, 2025
1519472
storage: Restore the original state of chunks
cosmo0920 Oct 10, 2025
eb72734
storage: Restore status of chunks for error paths
cosmo0920 Oct 10, 2025
615ef59
storage: internal: tests: Confirm the initial state of chunks
cosmo0920 Oct 10, 2025
29f41f6
engine: Tweak conditions for enabling DLQ
cosmo0920 Nov 10, 2025
f831f7f
filter_kubernetes: use service account issuer to detect EKS env
movence Nov 10, 2025
d814153
filter_kubernetes: aws: declare variable on top of the function
edsiper Nov 10, 2025
6bc0143
workflows: staging-release: add v4.2
edsiper Nov 11, 2025
f1ba23a
release: update to 4.2.1
edsiper Nov 12, 2025
73d20d0
workflows: Not to make latest on publishing 4.1 series on GitHub Relases
cosmo0920 Nov 15, 2025
0717103
in_forward: fix connection release on pause memory corruption
leonardo-albertovich Nov 9, 2025
4f8c50b
workflows: Remove unused tools from unit-tests workflow for extending…
cosmo0920 Nov 19, 2025
11802da
workflows: bump actions/checkout from 5 to 6
dependabot[bot] Nov 21, 2025
0e56bc2
in_opentelemetry: added five missing configuration option description…
eschabell Nov 21, 2025
f4108db
out_s3: implement retry_limit parameter
Sep 3, 2025
ae14454
in_blob: added missing configuration descriptions. Fixes #11204.
eschabell Nov 25, 2025
ef3f075
tls: openssl: Implement flexible certstore loading on Windows
cosmo0920 Nov 25, 2025
923dec2
tls: openssl: Handle location prefix more strictly
cosmo0920 Nov 25, 2025
10ebd3a
in_kubernetes_events: add support for configuring input upstream netw…
slab-msft Nov 21, 2025
045d516
workflows: add new commit linter tool
edsiper Dec 2, 2025
6901bb9
workflows: scripts: commit_prefix_check: validate only commits in act…
edsiper Dec 2, 2025
a5d6b73
docs: update COMMIT_LINT.md
edsiper Dec 2, 2025
fa4cc9d
workflows: scripts: test_commit_lint: add unit test (pytest)
edsiper Dec 2, 2025
a8f1e4b
docs: COMMIT_LINT.md: update instructions for unit tests
edsiper Dec 2, 2025
b2728ea
workflows: bump actions/checkout from 4 to 6
dependabot[bot] Dec 3, 2025
34f570b
workflows: bump actions/setup-python from 5 to 6
dependabot[bot] Dec 3, 2025
137771b
dockerfile: Docker image to support large page sizes
mlsorensen Nov 15, 2025
6007b03
dockerfile: allow customization of FLB_JEMALLOC_OPTIONS
mlsorensen Nov 17, 2025
77d82bc
dockerfile: update to Debian Trixie
patrick-stephens Oct 9, 2025
3766511
dockerfile: install systemd libs from normal repo
patrick-stephens Oct 9, 2025
3c4f8f4
in_elasticsearch: fixing missing config parameter description for htt…
eschabell Nov 28, 2025
1f37de5
in_exec_wasi: fix config key typo 'bool' -> 'oneshot'
eschabell Dec 1, 2025
c88c545
in_forward: improve configuration parameter descriptions
eschabell Dec 2, 2025
2a990fd
github: scripts: commit_linter: Extend a capability of prefix inferences
cosmo0920 Dec 4, 2025
200ad59
github: scripts: commit_linter: Fix failing test cases
cosmo0920 Dec 4, 2025
f2dd991
build: prevent the toolchain from emitting an executable stack
edsiper Dec 5, 2025
8cc6da6
in_forward: fix segfault and double-free in trace path handling
edsiper Dec 4, 2025
7ded9ae
in_node_exporter_metrics: Increase buffer size to read /proc/stat cor…
piwai Dec 4, 2025
12b191b
in_http: added missing config parameter descriptions.
eschabell Dec 2, 2025
86455b0
workflows: bump peter-evans/create-pull-request from 7 to 8
dependabot[bot] Dec 10, 2025
3a501b2
out_flowcounter: Fix incorrect bytes calculation (#11259)
cosmo0920 Dec 11, 2025
c06c124
workflows: bump actions/cache from 4 to 5
dependabot[bot] Dec 12, 2025
a915fce
workflows: bump actions/download-artifact from 6 to 7
dependabot[bot] Dec 15, 2025
5292d8c
workflows: bump actions/upload-artifact from 5 to 6
dependabot[bot] Dec 15, 2025
71d931c
github: workflows: Clean up needless resources on GHA workers
cosmo0920 Dec 15, 2025
ee1d69d
in_ebpf: add missing config option descriptions
eschabell Nov 28, 2025
275ef3b
in_gpu_metrics: updated config parameters descriptions.
eschabell Dec 2, 2025
6d6372b
build: Tweak linker flags for zstd
cosmo0920 Nov 5, 2025
483ff59
packaging: distros: almalinux: Use system installed libzstd only for 10
cosmo0920 Dec 10, 2025
372d5df
packaging: distros: centos: Use system libzstd on Stream 10
cosmo0920 Dec 11, 2025
9c211b6
packaging: distros: rockylinux: Use system's libzstd on Rockylinux10
cosmo0920 Dec 11, 2025
5a96ef5
build: Use bundled namespace instead of the simple zstd one
cosmo0920 Dec 12, 2025
eb9f9bd
build: Address fallbacking issue of finding libzstd
cosmo0920 Dec 13, 2025
282081f
in_winevtlog: Plug glitches of time offset for DST/STD switches
cosmo0920 Dec 15, 2025
909b1a9
in_winevtlog: Remove needless locale related lines
cosmo0920 Dec 15, 2025
702f4f1
packaging: script: Use rockylinux prefix on package testing script
cosmo0920 Dec 18, 2025
b9f26a9
release: update to 4.2.2
cosmo0920 Dec 18, 2025
b05bc20
security: Update supporting schedule
cosmo0920 Dec 18, 2025
c994082
out_cloudwatch_logs: increase MAX_EVENT_LEN to 1MB with tests
ShelbyZ Nov 12, 2025
3da0766
aws: Implement simple_aggregation operation
ShelbyZ Dec 19, 2025
f6c1c69
tests: aws_aggregation
ShelbyZ Dec 19, 2025
eb39164
out_kinesis_firehose: Add simple_aggregation operation
ShelbyZ Dec 19, 2025
94c4b50
tests: Add firehose test cases for simple_aggregation operation
ShelbyZ Dec 19, 2025
976938a
out_kinesis_streams: Add simple_aggregation operation
ShelbyZ Dec 19, 2025
0572b9c
tests: Add kinesis test cases for simple_aggregation operation
ShelbyZ Dec 19, 2025
735e641
out_kinesis_firehose: enable HTTP debugging for AWS client requests
runderwo Nov 21, 2025
588ef05
aws: utils: set up HTTP debug plumbing for AWS HTTP clients
runderwo Nov 21, 2025
1d38468
http_client: add ipv6 bracket if missing from host address
ShelbyZ Dec 23, 2025
1348732
tests: expand http_client tests for host headers
ShelbyZ Dec 23, 2025
f760d58
network: Add ws2tcpip.h to avoid missing func defs
ShelbyZ Dec 23, 2025
a959af8
utils: fix support for ipv6 addresses
ShelbyZ Dec 23, 2025
1676473
tests: add IPv4 and IPv6 tests for utils
ShelbyZ Dec 23, 2025
e9d8b5d
lib: sqlite: upgrade to v3.51.1
edsiper Dec 23, 2025
7caffd1
lib: c-ares: upgrade to v1.34.6
edsiper Dec 23, 2025
3683ce3
lib: monkey: upgrade to v1.8.6
edsiper Dec 23, 2025
96a31e3
lib: cmetrics: upgrade to v1.0.6
edsiper Dec 23, 2025
ddfef36
lib: luajit: upgrade to 7152e154 (20251223)
edsiper Dec 23, 2025
7b0c1ae
release: update to 4.2.3
edsiper Dec 24, 2025
cc4d8ef
core: update copyright year to 2026
edsiper Jan 1, 2026
a981f66
plugins: update copyright year to 2026
edsiper Jan 1, 2026
34f9ea9
filter_kubernetes: fix parser annotation leak
erain Jan 5, 2026
6b9c875
tests: add kubernetes parser annotation order case
erain Jan 5, 2026
d61eb7b
github: scripts: commit_linter: Handle bin prefix for fluent-bit.c
cosmo0920 Jan 5, 2026
2e7f2e8
github: scripts: commit_linter: Add test cases for entrypoint
cosmo0920 Jan 5, 2026
bf74f1d
bin: Handle CONT signal properly under leaks command
cosmo0920 Jan 5, 2026
ab34c0e
bin: Add NULL checks
cosmo0920 Jan 5, 2026
bafa3fc
filter_wasm: Handle group matadata
cosmo0920 Dec 22, 2025
54c225a
tests: Add a test case for group metadata handling
cosmo0920 Dec 22, 2025
9191f70
cmake: kafka: fix OAuth Bearer detection on Windows (#11294)
bp-cheng Jan 5, 2026
b0c026c
maintenance: update branches info
edsiper Jan 5, 2026
d0eeffb
security: set v4.0.x as EOL
edsiper Jan 5, 2026
bdde9e0
github: scripts: commit_prefix_check: Handle config_format prefix
cosmo0920 Jan 6, 2026
0c352ed
github: scripts: tests: Add test cases for config_format umbrella
cosmo0920 Jan 6, 2026
8a51336
github: scripts: commit_prefix_check: Tighten the rule
cosmo0920 Jan 6, 2026
9c41374
github: scripts: commit_prefix_check: Remove needless lines
cosmo0920 Jan 6, 2026
66e96d8
readme: update active branch
edsiper Jan 6, 2026
dcea262
out_opentelemetry: on HTTP/2, read and process gRPC status code
edsiper Jan 6, 2026
54a36fb
config_format: cf_yaml: lign the behavior of dirname against POSIX
cosmo0920 Jan 6, 2026
a2f64b9
filter: validate value property (not null)
edsiper Feb 2, 2026
527ca9f
processor: properly handle numeric values in config map
edsiper Feb 2, 2026
a1e82ab
filter_log_to_metrics: fix handling of init exceptions and cleanup
edsiper Feb 2, 2026
5a30d3e
out_stackdriver: clean up oauth2 cache lifecycle
erain Jan 2, 2026
a3c457f
filter_kubernetes: Adjust cleanup ordering to avoid use-after-free
ShelbyZ Feb 9, 2026
2be7535
in_winevtlog: Add text format for event rendering
cosmo0920 Feb 10, 2026
9939213
in_winevtlog: Plug memory errors on exceptions
cosmo0920 Feb 10, 2026
3bdac8c
in_winevtlog: Use different variables for collecting each of lengths
cosmo0920 Feb 10, 2026
7155725
in_tail: Add skipped_lines counter
cosmo0920 Feb 13, 2026
09e3780
in_tail: Handle only first occurrence for skipped lines
cosmo0920 Feb 13, 2026
8b5e517
in_splunk: Extract x-forwarded-for as a remote_addr record
cosmo0920 Jan 26, 2026
0192ac7
tests: in_splunk: Add a remote_addr extraction case
cosmo0920 Jan 26, 2026
4a3b205
tests: internal: aws: switch AWS Endpoints for European Souvereign Cloud
kabakakao Jan 7, 2026
0915933
aws: addtional changes mentioned by coderabbit
kabakakao Jan 8, 2026
a36b225
plugin_proxy: enable event_type specification for proxy plugins
jmccormick7 Feb 17, 2026
653f174
in_splunk: Plug memory issues
cosmo0920 Feb 17, 2026
40c2f27
github: workflows: free space
edsiper Feb 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
328 changes: 328 additions & 0 deletions .github/scripts/commit_prefix_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
#!/usr/bin/env python3
"""
Fluent Bit Commit Prefix Linter
---------------------------------
Validates commit messages according to Fluent Bit standards:
- Single prefix (plugin or subsystem)
- Prefix must match modified files
- No combined subjects (detect bad squashes)
- Multiple Signed-off-by lines allowed for real commits
- BUT detect_bad_squash(body) must still treat multiple signoffs as "bad squash"
(to satisfy test suite expectations)
- Subject <= 80 chars
"""

import os
import re
import sys
from git import Repo

repo = Repo(".")

# Regex patterns
PREFIX_RE = re.compile(r"^[a-z0-9_]+:", re.IGNORECASE)
SIGNED_OFF_RE = re.compile(r"Signed-off-by:", re.IGNORECASE)


# ------------------------------------------------
# Identify expected prefixes dynamically from file paths
# ------------------------------------------------
def infer_prefix_from_paths(paths):
"""
Returns:
- prefixes: a set of allowed prefixes (including build:)
- build_optional: True when commit subject does not need to be build:
(i.e., when any real component — lib/tests/plugins/src — is touched)
"""
prefixes = set()
component_prefixes = set()
build_seen = False

for raw in paths:
# Normalize path separators (Windows compatibility)
p = raw.replace(os.sep, "/")
basename = os.path.basename(p)

# ----- Any CMakeLists.txt → build: candidate -----
if basename == "CMakeLists.txt":
build_seen = True

# ----- lib/ → lib: -----
if p.startswith("lib/"):
component_prefixes.add("lib:")

# ----- tests/ → tests: -----
if p.startswith("tests/"):
component_prefixes.add("tests:")

# ----- plugins/<name>/ → <name>: -----
if p.startswith("plugins/"):
parts = p.split("/")
if len(parts) > 1:
component_prefixes.add(f"{parts[1]}:")

# ----- src/ → flb_xxx.* → xxx: OR src/<dir>/ → <dir>: -----
# ----- src/ handling -----
if p.startswith("src/"):
parts = p.split("/")
filename = os.path.basename(p)

# src/fluent-bit.c → bin:
if filename == "fluent-bit.c":
component_prefixes.add("bin:")
continue

# src/flb_xxx.c → xxx:
if len(parts) == 2 and filename.startswith("flb_"):
core = filename[4:].split(".")[0]
component_prefixes.add(f"{core}:")
continue

# src/<dir>/... → <dir>:
if len(parts) > 2:
src_dir = parts[1]
component_prefixes.add(f"{src_dir}:")
continue


# prefixes = component prefixes + build: if needed
prefixes |= component_prefixes
if build_seen:
prefixes.add("build:")

# build_optional:
# True if ANY real component (lib/tests/plugins/src) was modified.
# False only when modifying build system files alone.
build_optional = len(component_prefixes) > 0

return prefixes, build_optional


# ------------------------------------------------
# detect_bad_squash() must satisfy the tests EXACTLY
# ------------------------------------------------
def detect_bad_squash(body):
"""
Tests expect:
- ANY prefix-like line in body → BAD
- IF multiple prefix lines → BAD with message starting "Multiple subject-like prefix lines"
- Multiple Signed-off-by lines in body → BAD (ONLY for this function)
"""

# Normalize and discard empty lines
lines = [l.strip() for l in body.splitlines() if l.strip()]

prefix_lines = [l for l in lines if PREFIX_RE.match(l)]
signoffs = SIGNED_OFF_RE.findall(body)

# Multiple prefix lines
if len(prefix_lines) > 1:
return True, f"Multiple subject-like prefix lines detected: {prefix_lines}"

# Single prefix line in body → also bad (test_error_bad_squash_detected)
if len(prefix_lines) == 1:
return True, f"Unexpected subject-like prefix in body: {prefix_lines}"

# Multiple sign-offs → bad squash per test_bad_squash_multiple_signoffs
if len(signoffs) > 1:
return True, "Multiple Signed-off-by lines detected (bad squash)"

return False, ""


# ------------------------------------------------
# Validate commit based on expected behavior and test rules
# ------------------------------------------------
def validate_commit(commit):
msg = commit.message.strip()
first_line, *rest = msg.split("\n")
body = "\n".join(rest)

# Subject must start with a prefix
subject_prefix_match = PREFIX_RE.match(first_line)
if not subject_prefix_match:
return False, f"Missing prefix in commit subject: '{first_line}'"

subject_prefix = subject_prefix_match.group()

# Run squash detection (but ignore multi-signoff errors)
bad_squash, reason = detect_bad_squash(body)

# If bad squash was caused by prefix lines in body → FAIL
# If list of prefix lines in body → FAIL
if bad_squash:
# Prefix-like lines are always fatal
if "subject-like prefix" in reason:
return False, f"Bad squash detected: {reason}"

# If due to multiple sign-offs, tests expect validate_commit() to still PASS
# So we do NOT return False here.
# validate_commit ignores multi signoff warnings.
pass

# Subject length check
if len(first_line) > 80:
return False, f"Commit subject too long (>80 chars): '{first_line}'"

# Signed-off-by required
signoff_count = len(SIGNED_OFF_RE.findall(body))
if signoff_count == 0:
return False, "Missing Signed-off-by line"

# Determine expected prefixes + build option flag
files = commit.stats.files.keys()
expected, build_optional = infer_prefix_from_paths(files)

# When no prefix can be inferred (docs/tools), allow anything
if len(expected) == 0:
return True, ""

expected_lower = {p.lower() for p in expected}
subj_lower = subject_prefix.lower()


# ------------------------------------------------
# config_format conditional umbrella rule
# ------------------------------------------------
if "config_format:" in expected_lower:
non_build = {
p for p in expected_lower
if p not in ("build:", "cmakelists.txt:")
}

# Allow ONLY if all non-build prefixes are config_format:
if non_build != {"config_format:"}:
return False, (
f"Subject prefix '{subject_prefix}' does not match files changed.\n"
f"config_format commits must not include other components."
)

# ------------------------------------------------
# Multiple-component detection
# ------------------------------------------------
# Treat pure build-related prefixes ("build:", "CMakeLists.txt:") as non-components.
# Additionally, allow lib: to act as an umbrella for lib subcomponents
# (e.g., ripser:, ripser_wrapper:) when subject prefix is lib:.
non_build_prefixes = {
p
for p in expected_lower
if p not in ("build:", "cmakelists.txt:")
}

# Prefixes that are allowed to cover multiple subcomponents
umbrella_prefixes = {"lib:"}

# If more than one non-build prefix is inferred AND the subject is not an umbrella
# prefix, require split commits.
if len(non_build_prefixes) > 1 and subj_lower not in umbrella_prefixes:
expected_list = sorted(expected)
expected_str = ", ".join(expected_list)
return False, (
f"Subject prefix '{subject_prefix}' does not match files changed.\n"
f"Expected one of: {expected_str}"
)

# Subject prefix must be one of the expected ones
if subj_lower not in expected_lower:
expected_list = sorted(expected)
expected_str = ", ".join(expected_list)
return False, (
f"Subject prefix '{subject_prefix}' does not match files changed.\n"
f"Expected one of: {expected_str}"
)


# If build is NOT optional and build: exists among expected,
# then subject MUST be build:
if not build_optional and "build:" in expected_lower and subj_lower != "build:":
return False, (
f"Subject prefix '{subject_prefix}' does not match files changed.\n"
f"Expected one of: build:"
)

return True, ""


# ------------------------------------------------
# Get PR commits only (excludes merge commits and base branch commits)
# ------------------------------------------------
def get_pr_commits():
"""
For PRs, get only commits that are part of the PR (not in base branch).
Excludes merge commits.
"""
event_name = os.environ.get("GITHUB_EVENT_NAME", "")
base_ref = os.environ.get("GITHUB_BASE_REF", "")

if event_name != "pull_request":
return [repo.head.commit]

# Try to get the base branch reference
base_branch_ref = None
if base_ref:
# Try origin/base_ref first (most common in CI)
try:
base_branch_ref = f"origin/{base_ref}"
repo.refs[base_branch_ref] # Test if it exists
except (KeyError, IndexError):
# Try just base_ref if origin/ doesn't exist
try:
base_branch_ref = base_ref
repo.refs[base_branch_ref] # Test if it exists
except (KeyError, IndexError):
base_branch_ref = None

# If we have a base branch, get commits between base and HEAD
if base_branch_ref:
try:
base_commit = repo.refs[base_branch_ref].commit
merge_base_list = repo.merge_base(repo.head.commit, base_commit)
if merge_base_list:
merge_base_sha = merge_base_list[0].hexsha
# Get all commits from merge_base to HEAD, excluding merge_base itself
pr_commits = list(repo.iter_commits(f"{merge_base_sha}..HEAD"))
# Filter out merge commits (they start with "Merge")
pr_commits = [c for c in pr_commits if not c.message.strip().startswith("Merge")]
if pr_commits:
return pr_commits
except Exception as e:
# If merge-base fails, log and fall through to fallback
print(f"⚠️ Could not determine merge base: {e}", file=sys.stderr)

# Fallback: if we can't determine base, check HEAD (but skip if it's a merge)
head_commit = repo.head.commit
if head_commit.message.strip().startswith("Merge"):
# If HEAD is a merge commit, skip it
print("⚠️ HEAD is a merge commit and base branch not available. Skipping validation.", file=sys.stderr)
return []

return [head_commit]


# ------------------------------------------------
# MAIN
# ------------------------------------------------
def main():
commits = get_pr_commits()

if not commits:
print("ℹ️ No commits to validate.")
sys.exit(0)

errors = []
for commit in commits:
ok, reason = validate_commit(commit)
if not ok:
errors.append(f"\n❌ Commit {commit.hexsha[:10]} failed:\n{reason}\n")

if errors:
print("".join(errors))
print("\nCommit prefix validation failed.")
sys.exit(1)

print("✅ Commit prefix validation passed.")
sys.exit(0)


if __name__ == "__main__":
main()
Loading
Loading