Skip to content

Commit ffffa03

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

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

src/flb_config.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,6 @@ static int configure_plugins_type(struct flb_config *config, struct flb_cf *cf,
795795
flb_sds_destroy(name);
796796
return -1;
797797
}
798-
flb_sds_destroy(name);
799798

800799
/*
801800
* iterate section properties and populate instance by using specific
@@ -857,6 +856,8 @@ static int configure_plugins_type(struct flb_config *config, struct flb_cf *cf,
857856
flb_error("[config] could not configure property '%s' on "
858857
"%s plugin with section name '%s'",
859858
kv->key, s_type, name);
859+
flb_sds_destroy(name);
860+
return -1;
860861
}
861862
}
862863

@@ -873,6 +874,8 @@ static int configure_plugins_type(struct flb_config *config, struct flb_cf *cf,
873874
flb_error("[config] section '%s' does not support processors", s_type);
874875
}
875876
}
877+
878+
flb_sds_destroy(name);
876879
}
877880

878881
return 0;

tests/internal/config_format_yaml.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,27 @@ static void test_upstream_servers()
833833
flb_cf_destroy(cf);
834834
}
835835

836+
static void test_invalid_property()
837+
{
838+
struct flb_cf *cf;
839+
struct flb_config *config;
840+
int ret;
841+
int i;
842+
char* file_path = FLB_TESTS_CONF_PATH "/invalid_input_property.yaml";
843+
844+
cf = flb_cf_yaml_create(NULL, file_path, NULL, 0);
845+
TEST_ASSERT(cf != NULL);
846+
847+
config = flb_config_init();
848+
TEST_ASSERT(config != NULL);
849+
850+
ret = flb_config_load_config_format(config, cf);
851+
TEST_ASSERT_(ret == -1, "expected invalid property to return an error in file %s", file_path);
852+
853+
flb_cf_destroy(cf);
854+
flb_config_exit(config);
855+
}
856+
836857
TEST_LIST = {
837858
{ "basic" , test_basic},
838859
{ "customs section", test_customs_section},
@@ -846,5 +867,6 @@ TEST_LIST = {
846867
{ "stream_processor", test_stream_processor},
847868
{ "plugins", test_plugins},
848869
{ "upstream_servers", test_upstream_servers},
870+
{ "invalid_input_property", test_invalid_property},
849871
{ 0 }
850872
};
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)