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

If invalid JSON is passed to jq.promised.raw all future runs an empty string #14

Open
mandatoryprogrammer opened this issue Nov 8, 2019 · 3 comments

Comments

@mandatoryprogrammer
Copy link

When using jq.promised.raw, if you pass an invalid <json-string> as input then all future calls to jq.promised.raw will return an empty string "".

Example:

// Pass invalid JSON in
await jq.promised.raw('{#@#}', '.');
// Result of the above is an empty string still.

// Pass in valid JSON
await jq.promised.raw('{"test":"test"}', '.');
// Result of the above is an empty string still.

This bug tripped me up but I figured out what causes it, let me know if you need more reproduction information.

@fiatjaf
Copy link
Owner

fiatjaf commented Nov 9, 2019

No, I want the solution!

@mandatoryprogrammer
Copy link
Author

I don't know how to fix this one. I fixed it in my own code by doing an initial JSON.parse of the input JSON inside of a try/catch and returning an error instead of passing it to jq.promise.raw.

@tyleradams
Copy link

@fiatjaf We also hit this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants