Skip to content

Commit e85d7f7

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

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,34 @@ static void test_upstream_servers()
833833
flb_cf_destroy(cf);
834834
}
835835

836+
static void test_invalid_property()
837+
{
838+
char* test_cases[] = {
839+
FLB_TESTS_CONF_PATH "/invalid_input_property.yaml",
840+
FLB_TESTS_CONF_PATH "/invalid_output_property.yaml",
841+
NULL,
842+
};
843+
844+
struct flb_cf *cf;
845+
struct flb_config *config;
846+
int ret;
847+
int i;
848+
849+
for (i = 0; test_cases[i] != NULL; i++) {
850+
cf = flb_cf_yaml_create(NULL, test_cases[i], NULL, 0);
851+
TEST_ASSERT(cf != NULL);
852+
853+
config = flb_config_init();
854+
TEST_ASSERT(config != NULL);
855+
856+
ret = flb_config_load_config_format(config, cf);
857+
TEST_ASSERT_(ret == -1, "expected invalid property to return an error in file %s", test_cases[i]);
858+
859+
flb_cf_destroy(cf);
860+
flb_config_exit(config);
861+
}
862+
}
863+
836864
TEST_LIST = {
837865
{ "basic" , test_basic},
838866
{ "customs section", test_customs_section},
@@ -846,5 +874,6 @@ TEST_LIST = {
846874
{ "stream_processor", test_stream_processor},
847875
{ "plugins", test_plugins},
848876
{ "upstream_servers", test_upstream_servers},
877+
{ "invalid_input_property", test_invalid_property},
849878
{ 0 }
850879
};
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)