Skip to content

Conversation

@pwhelan
Copy link
Contributor

@pwhelan pwhelan commented Mar 19, 2025

Summary

Fix return value for flb_ra_get_kv_pair when get_ra_parser fails.

Description

When a record accesor is created but has no hints, usually because it is invalid or truncated, it will be generated without any hints. When that happens the call get_ra_parser fails. The function flb_ra_get_kv_pair calls get_ra_parser as well as flb_ra_key_value_get. If get_ra_parser fails it returns FLB_FALSE but the function returns the value of flb_ra_key_value_get directly which returns 0 on success and -1 on failure.

All of this weird, unexpected behaviour casues a failure in the structured_metadata_map_invalid_ra_key test in the flb-rt-out_loki test binary.

To remedy the situation I updated the documentation for flb_ra_get_kv_pair as well as updated the return value when failing get_ra_parser to -1. I double checked all code calling flb_ra_get_kv_pair:

  • src/flb_mp.c
  • src/flb_record_accessor.c
  • plugins/out_loki/loki.c
  • plugins/filter_modify/modify.c
  • plugins/filter_type_converter/type_converter.c
  • plugins/out_http/http.c
  • plugins/out_opentelemetry/opentelemetry_logs.c

All of these files expect the convention laid out by flb_ra_key_value_get.

This should fix the tests added in #9530.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

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

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

Documentation

  • Documentation required for this feature

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.

…arser fails.

Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
@patrick-stephens
Copy link
Collaborator

patrick-stephens commented Mar 20, 2025

@pwhelan can we backport to 3.2 too as the change was merged there as well? Or @0x006EA1E5 if you can do it?

@patrick-stephens patrick-stephens merged commit 9dd2094 into master Mar 20, 2025
111 of 112 checks passed
@patrick-stephens patrick-stephens deleted the pwhelan-fix-out-loki-invalid-ra-key-test branch March 20, 2025 10:45
@0x006EA1E5
Copy link
Contributor

@pwhelan can we backport to 3.2 too as the change was merged there as well? Or @0x006EA1E5 if you can do it?

Here is a PR to backport this #10108

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

Labels

ok-package-test Run PR packaging tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants