diff --git a/changelog/unreleased/bug-fixes/1759--json-import-abort.md b/changelog/unreleased/bug-fixes/1759--json-import-abort.md new file mode 100644 index 00000000000..eb3843327d2 --- /dev/null +++ b/changelog/unreleased/bug-fixes/1759--json-import-abort.md @@ -0,0 +1,3 @@ +VAST does not abort an import of JSON data anymore when encountering +something other than a JSON object (ie. a number or a string). +Instead, the offending line is skipped. diff --git a/libvast/vast/format/json.hpp b/libvast/vast/format/json.hpp index 9ac243ddd6e..7ce42fa5480 100644 --- a/libvast/vast/format/json.hpp +++ b/libvast/vast/format/json.hpp @@ -192,8 +192,13 @@ caf::error reader::read_impl(size_t max_events, size_t max_slice_size, continue; } auto get_object_result = parse_result.get_object(); - if (get_object_result.error() != ::simdjson::error_code::SUCCESS) - return caf::make_error(ec::type_clash, "not a json object"); + if (get_object_result.error() != ::simdjson::error_code::SUCCESS) { + if (num_invalid_lines_ == 0) + VAST_WARN("{} failed to parse line as JSON object {}: {}", + detail::pretty_type_name(this), lines_->line_number(), line); + ++num_invalid_lines_; + continue; + } auto&& layout = selector_(get_object_result.value()); if (!layout) { if (num_unknown_layouts_ == 0)