jqlang / jq

Command-line JSON processor
https://jqlang.github.io/jq/
Other
30.64k stars 1.58k forks source link

Error with pipe in jq but not error if I first redirect output to a file #3201

Open mmm286 opened 2 weeks ago

mmm286 commented 2 weeks ago

Hi, I'm trying to do a pipe with jq to parser an api output and it gives me error:

ctm run jobs:status::get -s "status=Ended Not OK" | jq '.returned'
parse error: Unfinished string at EOF at line 2072, column 57

However if I redirect to a file I don't have any problem:

ctm run jobs:status::get -s "status=Ended Not OK" > errors
cat errors | jq '.returned'
361

Thanks

wader commented 2 weeks ago

Does ... | tee errors | jq also fail? if so could you post the whole or part of the errors file?

mmm286 commented 2 weeks ago

Does ... | tee errors | jq also fail? if so could you post the whole or part of the errors file?

ctm run jobs:status::get -s "status=Ended Not OK" | tee errors | jq '.'
parse error: Unfinished string at EOF at line 2069, column 37
wader commented 2 weeks ago

And how does the errors file look like? judging by the error message it seems like the file ends in the middle of a quoted string. If so i would guess the problem happens before jq, ex ctm for some reason behaving different when stdout is a file or pipe (buffer issues?), broken disk?

wader commented 2 weeks ago

@mmm286 did figure it out? close issue?