algorithmiaio/langpacks

Python langpack crash on receiving invalid JSON

Opened this issue · 4 comments

pmcq commented

This shouldn't ever happen with langserver sending data, but the result would be a confusing error message to the user:
https://github.com/algorithmiaio/langpacks/blob/master/python/template/bin/pipe.py#L28

I'm confused given that "this shouldn't ever happen". Do you just mean that we should still try-catch these lines for the sake of good practice?

Also note that if JSON parsing is aggressively minimized then this langpack JSON parse is the only place that is absolutely required to perform a JSON parse (all other pieces in the stack can theoretically pass it blind) so if these caught malformed JSON in a standardized way then the extra parsing steps can be removed.

pmcq commented

I mean more that we've tested the langserver and it shouldn't send bad JSON; but I was testing the pipe script directly (outside of langserver) and had issues. But yeah, mostly for good practice, help prevent if there was a bug in langserver too etc. I just wanted to call it out since in Go langpack I'm doing an explicit

if err := json.Unmarshal(input, &r); err != nil {
 // return SystemFailure
}

I don't suppose I have to, but just thought consistency across would be ideal (mostly in that the user would probably just see an process died exit 99 type error)