filter_kubernetes: on merge json, validate one record only
@@ -99,6 +99,7 @@ static int merge_log_handler(msgpack_object o,
int ret;
int new_size;
int root_type;
+ int records = 0;
char *tmp;
/* Reset vars */
@@ -149,14 +150,23 @@ static int merge_log_handler(msgpack_object o,
}
}
else { /* Default JSON parser */
- ret = flb_pack_json(ctx->unesc_buf, ctx->unesc_buf_len,
- (char **) out_buf, out_size, &root_type);
+ ret = flb_pack_json_recs(ctx->unesc_buf, ctx->unesc_buf_len,
+ (char **) out_buf, out_size, &root_type,
+ &records);
if (ret == 0 && root_type != FLB_PACK_JSON_OBJECT) {
flb_plg_debug(ctx->ins, "could not merge JSON, root_type=%i",
root_type);
flb_free(*out_buf);
return MERGE_NONE;
}
+
+ if (ret == 0 && records != 1) {
+ flb_plg_debug(ctx->ins,
+ "could not merge JSON, invalid number of records: %i",
+ records);
+ flb_free(*out_buf);
+ return MERGE_NONE;
+ }
}
if (ret == -1) {
