Skip to content
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

Bugfix: conf: Handle null values correctly (as if they don't exist) and fail some invalid cases more gracefully #48

Merged
merged 1 commit into from
Dec 14, 2024
Merged
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
6 changes: 3 additions & 3 deletions src/datum_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,18 @@ int datum_read_config(const char *conffile) {

config = load_json_from_file(conffile);

if (!config) {
if (!json_is_object(config)) {
DLOG_FATAL("Could not read configuration JSON file!");
return -1;
}

for (i=0;i<NUM_CONFIG_ITEMS;i++) {
item = NULL; cat = NULL;
cat = json_object_get(config, datum_config_options[i].category);
if (cat) {
if (json_is_object(cat)) {
item = json_object_get(cat, datum_config_options[i].name);
}
if ((!cat) || (!item)) {
if ((!item) || json_is_null(item)) {
if (datum_config_options[i].required) {
DLOG_ERROR("Required configuration option (%s.%s) not found in config file:", datum_config_options[i].category, datum_config_options[i].name);
DLOG_ERROR("--- Config description: \"%s\"", datum_config_options[i].description);
Expand Down
Loading