Skip to content

Gracefully deal with JSON to data conversion errors #1250

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

Merged
merged 4 commits into from
Dec 21, 2020

Conversation

tobim
Copy link
Member

@tobim tobim commented Dec 21, 2020

📔 Description

📝 Checklist

  • All user-facing changes have changelog entries.
  • The PR description contains instructions for the reviewer, if necessary.

🎯 Review Instructions

Please test modifying the suricata schema and ingesting test data from the repo. Everything but the modified field should remain intact upon export.

@tobim tobim added the bug Incorrect behavior label Dec 21, 2020
@tobim tobim requested a review from mavam December 21, 2020 11:27
err = make_error(ec::convert_error);
err.context() += x.error().context();
err.context() += caf::make_message("could not convert", field.name, ":",
to_string(*i));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use += twice?
Can you give an example of how a "multi-field" error would look like?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example with 2 conversion errors in one line:

vast.format.json.reader failed to convert value(s) in line 1 : !! convert_error: "long%20double" "to" "vast.string_type" "pcap_cnt" "is" "83" ";" "long%20double" "to" "vast.string_type" "src_port" "is" "1181" ";"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it may be complete in terms of information, it's pretty rough to understand.

In the future, we probably want to use std::format to print a human-readable error message, so for now I'm fine with keeping it as is.

@tobim tobim merged commit 9397e8e into master Dec 21, 2020
@tobim tobim deleted the story/ch21301/json-reader-stay-in-sync branch December 21, 2020 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants