Skip to content

Commit df46f10

Browse files
committed
config: minor fixes in configure_plugins_type
Signed-off-by: Bradley Laney <[email protected]>
1 parent 5905ddc commit df46f10

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

src/flb_config.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,6 @@ static int configure_plugins_type(struct flb_config *config, struct flb_cf *cf,
804804
flb_sds_destroy(name);
805805
return -1;
806806
}
807-
flb_sds_destroy(name);
808807

809808
/*
810809
* iterate section properties and populate instance by using specific
@@ -866,6 +865,8 @@ static int configure_plugins_type(struct flb_config *config, struct flb_cf *cf,
866865
flb_error("[config] could not configure property '%s' on "
867866
"%s plugin with section name '%s'",
868867
kv->key, s_type, name);
868+
flb_sds_destroy(name);
869+
return -1;
869870
}
870871
}
871872

@@ -888,6 +889,8 @@ static int configure_plugins_type(struct flb_config *config, struct flb_cf *cf,
888889
flb_error("[config] section '%s' does not support processors", s_type);
889890
}
890891
}
892+
893+
flb_sds_destroy(name);
891894
}
892895

893896
return 0;

tests/internal/config_format_yaml.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
22

33
#include <fluent-bit/flb_info.h>
4+
#include <fluent-bit/flb_input.h>
45
#include <fluent-bit/flb_mem.h>
56
#include <fluent-bit/flb_kv.h>
67
#include <fluent-bit/flb_str.h>
@@ -833,6 +834,35 @@ static void test_upstream_servers()
833834
flb_cf_destroy(cf);
834835
}
835836

837+
static void test_invalid_property()
838+
{
839+
char* test_cases[] = {
840+
FLB_TESTS_CONF_PATH "/invalid_input_property.yaml",
841+
FLB_TESTS_CONF_PATH "/invalid_output_property.yaml",
842+
NULL,
843+
};
844+
845+
struct flb_cf *cf;
846+
struct flb_config *config;
847+
int ret;
848+
int i;
849+
850+
for (i = 0; test_cases[i] != NULL; i++) {
851+
cf = flb_cf_yaml_create(NULL, test_cases[i], NULL, 0);
852+
TEST_ASSERT(cf != NULL);
853+
854+
config = flb_config_init();
855+
TEST_ASSERT(config != NULL);
856+
857+
ret = flb_config_load_config_format(config, cf);
858+
TEST_ASSERT_(ret == -1, "expected invalid property to return an error in file %s", test_cases[i]);
859+
860+
flb_cf_destroy(cf);
861+
flb_config_exit(config);
862+
flb_input_exit_all(config);
863+
}
864+
}
865+
836866
TEST_LIST = {
837867
{ "basic" , test_basic},
838868
{ "customs section", test_customs_section},
@@ -846,5 +876,6 @@ TEST_LIST = {
846876
{ "stream_processor", test_stream_processor},
847877
{ "plugins", test_plugins},
848878
{ "upstream_servers", test_upstream_servers},
879+
{ "invalid_input_property", test_invalid_property},
849880
{ 0 }
850881
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pipeline:
2+
inputs:
3+
- name: dummy
4+
log_level: thisdoesnotexist
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pipeline:
2+
outputs:
3+
- name: stdout
4+
match: '*'
5+
log_level: thisdoesnotexist

0 commit comments

Comments
 (0)