Skip to content

config: error configure_plugins_type on invalid properties #10296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/flb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,6 @@ static int configure_plugins_type(struct flb_config *config, struct flb_cf *cf,
flb_sds_destroy(name);
return -1;
}
flb_sds_destroy(name);

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

Expand All @@ -873,6 +874,8 @@ static int configure_plugins_type(struct flb_config *config, struct flb_cf *cf,
flb_error("[config] section '%s' does not support processors", s_type);
}
}

flb_sds_destroy(name);
}

return 0;
Expand Down
33 changes: 33 additions & 0 deletions tests/internal/config_format_yaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,38 @@ static void test_upstream_servers()
flb_cf_destroy(cf);
}

static void test_invalid_property()
{
char* test_cases[] = {
FLB_TESTS_CONF_PATH "/invalid_input_property.yaml",
FLB_TESTS_CONF_PATH "/invalid_output_property.yaml",
NULL,
};

struct flb_cf *cf;
struct flb_config *config;
int ret;
int i;

for (i = 0; test_cases[i] != NULL; i++) {
cf = flb_cf_yaml_create(NULL, test_cases[i], NULL, 0);
TEST_ASSERT(cf != NULL);

config = flb_config_init();
if (TEST_CHECK(config != NULL)) {
flb_cf_destroy(cf);
continue;
}

ret = flb_config_load_config_format(config, cf);
if (TEST_CHECK(ret != -1)) {
TEST_MSG("expected invalid property to return an error in file %s", test_cases[i]);
flb_cf_destroy(cf);
flb_config_exit(config);
}
}
}

TEST_LIST = {
{ "basic" , test_basic},
{ "customs section", test_customs_section},
Expand All @@ -846,5 +878,6 @@ TEST_LIST = {
{ "stream_processor", test_stream_processor},
{ "plugins", test_plugins},
{ "upstream_servers", test_upstream_servers},
{ "invalid_input_property", test_invalid_property},
{ 0 }
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pipeline:
inputs:
- name: dummy
log_level: thisdoesnotexist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pipeline:
outputs:
- name: stdout
match: '*'
log_level: thisdoesnotexist