diff --git a/src/datajson.c b/src/datajson.c index cdd0e5e968a..c85569aeaa7 100644 --- a/src/datajson.c +++ b/src/datajson.c @@ -330,6 +330,7 @@ static int DatajsonLoadString(Dataset *set, char *json_key, char *array_key) fclose(fp); } else { json_t *json; + bool found = false; if (ParseJsonFile(set->load, &json, array_key) == -1) return -1; @@ -340,10 +341,13 @@ static int DatajsonLoadString(Dataset *set, char *json_key, char *array_key) json_t *key = GetSubObjectByKey(value, json_key); if (key == NULL) { - FatalErrorOnInit("Can't find expected key '%s' in object", json_key); + /* ignore error as it can be a working mode where some entries + are not in the same format */ continue; } + found = true; + const char *val = json_string_value(key); DataJsonType json = { .value = NULL, .len = 0 }; @@ -359,6 +363,12 @@ static int DatajsonLoadString(Dataset *set, char *json_key, char *array_key) } } json_decref(json); + + if (found == false) { + FatalErrorOnInit( + "No valid entries for key '%s' found in the file '%s'", json_key, set->load); + return -1; + } } THashConsolidateMemcap(set->hash);