Skip to content

Commit 82e5741

Browse files
committed
config: minor fixes in configure_plugins_type
1 parent 757b13d commit 82e5741

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
@@ -165,6 +165,34 @@ static void test_basic()
165165
flb_cf_destroy(cf);
166166
}
167167

168+
static void test_invalid_input_property()
169+
{
170+
char* test_cases[] = {
171+
FLB_TESTS_CONF_PATH "/invalid_input_property.yaml",
172+
FLB_TESTS_CONF_PATH "/invalid_output_property.yaml",
173+
NULL,
174+
};
175+
176+
struct flb_cf *cf;
177+
struct flb_config *config;
178+
int ret;
179+
int i;
180+
181+
for (i = 0; test_cases[i] != NULL; i++) {
182+
cf = flb_cf_yaml_create(NULL, test_cases[i], NULL, 0);
183+
TEST_ASSERT(cf != NULL);
184+
185+
config = flb_config_init();
186+
TEST_ASSERT(config != NULL);
187+
188+
ret = flb_config_load_config_format(config, cf);
189+
TEST_ASSERT_(ret == -1, "expected invalid property to return an error in file %s", test_cases[i]);
190+
191+
flb_cf_destroy(cf);
192+
flb_config_exit(config);
193+
}
194+
}
195+
168196
/* https://github.com/fluent/fluent-bit/issues/7559 */
169197
static void test_customs_section()
170198
{
@@ -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_input_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)