Skip to content

Conversation

@adrian-kong
Copy link
Contributor

@adrian-kong adrian-kong commented Nov 21, 2022

Description

Logs error, terminates the unterminating json bug

JIRA Reference

https://swift-nav.atlassian.net/browse/DEVINFRA-1018

Copy link
Contributor

@silverjam silverjam left a comment

Choose a reason for hiding this comment

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

Can we do the same thing for fatal errors too?

@adrian-kong
Copy link
Contributor Author

Can we do the same thing for fatal errors too?

yep but will need to take until inclusive or chain (?) or just panic on the filter map 🤔 which i have just opted for the panic ^^

another bug (?) that arises json2sbp never terminates i.e.

echo {"crc":10555,"length":17,"msg_type":2304,"payload":"xYZjQJhhAWwAYhDy/3v+DgA=","preamble":85,"sender":51228,"tow":1080264389,"tow_f":152,"acc_x":353,"acc_y":108,"acc_z":4194,"gyr_x":1-14,"gyr_y":-389,"gyr_z":14} | cargo run --bin json2sbp

will not terminate which might look into (?) but we have --fatal-errors option

the above might be the reason why sometimes it doesn't produce back the entire sbp file, hanging the decoder

@adrian-kong adrian-kong marked this pull request as ready for review November 21, 2022 03:17
@adrian-kong adrian-kong requested a review from a team November 21, 2022 03:42
@adrian-kong adrian-kong changed the title Error logging in converters Error logging in converters [DEVINFRA-1018] Nov 21, 2022
@silverjam
Copy link
Contributor

If we don't dump the buffer on EOF errors, we terminate processing but we also don't capture the error, for example:

❯ echo -e '{"msg_type":1' | cargo run --quiet --bin json2sbp --
# ... no output ...

❯ echo -e '{"msg_type":1' | cargo run --quiet --bin json2sbp -- --fatal-errors
# ... no outputs ...

Versus previously

❯ echo -e '{"msg_type":1' | cargo run --quiet --bin json2sbp --
SerdeJsonError(Error("EOF while parsing an object", line: 2, column: 0))

❯ echo -e '{"msg_type":1' | cargo run --quiet --bin json2sbp -- --fatal-errors
SerdeJsonError(Error("EOF while parsing an object", line: 2, column: 0))

@silverjam
Copy link
Contributor

silverjam commented Nov 22, 2022

@adrian-kong You're change is probably correct, but it would be nice if we could detect an EOF error where we're at the true end of a stream vs an EOF in the decoder, which looks like it can also happen when we the buffer doesn't contain an entire JSON message.

@silverjam
Copy link
Contributor

@adrian-kong I wonder how hard it would be to add some integration tests for the error message?

fn new() -> Self {
JsonDecoder {
payload_buf: Vec::with_capacity(BUFLEN),
eof_seen: false,
Copy link
Contributor Author

@adrian-kong adrian-kong Nov 22, 2022

Choose a reason for hiding this comment

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

was trying to figure out a better way instead of holding this - felt hacky but i guess it works 👍 - or maybe just eprintln inside decode, thought the dencode errors meant retry decoding so we needed two error types

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree that the solution is a bit hacky. However, since these are library functions, it didn't feel right to add eprintln there (printing errors should be an application layer behavior).

@adrian-kong adrian-kong merged commit f864640 into master Nov 22, 2022
@adrian-kong adrian-kong deleted the adrian/sbp_converters_logging branch November 22, 2022 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants