Skip to content
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

improve error messaging when I'm holding it wrong #97

Open
seebs opened this issue Sep 6, 2023 · 1 comment
Open

improve error messaging when I'm holding it wrong #97

seebs opened this issue Sep 6, 2023 · 1 comment

Comments

@seebs
Copy link

seebs commented Sep 6, 2023

This is probably related-ish to #83.

I saw a note about this, thought "hey what a cool tool", tried to write things that would use spyql to read json. Consistently got page-long stack backtraces showing various errors from uncaught exceptions, usually coming down to:

[...]
  File "/Users/seebs/py3/lib/python3.11/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
               ^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 1 (char 2)

This is a very confusing error.

The actual problem: My input was the result of using jq on something, so it looked like ```
{
"id": 0,
"x": "foo"
}


What I wanted was the result of using `jq -c` on something, which would have looked like ```
{"id": 0, "x": "foo"}```

I don't dispute that I'm holding it wrong, but it feels to me like it would potentially be practical to check for the json decode error, and report something more useful rather than the stack backtrace. And, in particular, perhaps to point out "inputs are expected to be self-contained JSON objects on each line, not multiline pretty-printed constructs".
@dcmoura
Copy link
Owner

dcmoura commented Oct 8, 2023

Hey. You are totally right, regarding the stack trace. This behavior happens in parts of the code where there is no error handling, which seems to be the case for JSON reading/decoding.

And yes, regarding JSON input, SPyQL only supports JSON lines, which means one input line should be a complete JSON object. If you are piping from jq, you can simply add the -c option to the jq command (I do it all the time).

Thank you so much for your feedback! I will look into the issue and try to improve this behavior.

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

No branches or pull requests

2 participants