zui icon indicating copy to clipboard operation
zui copied to clipboard

Comments in Zed code not handled cleanly

Open philrz opened this issue 1 year ago • 0 comments

Repro is with Brim commit 55d1fdc0.

As shown in the following video (test data is sample.zng), adding a comment to a working Zed script caused it to stop returning results.

https://user-images.githubusercontent.com/5934157/180063284-688449e7-942c-403e-bc5d-f1bdfa215983.mp4

On closer inspection, i think I see the problem. Sniffing in Wireshark shows how the app tacks on more pipeline elements to help with pagination of results.

{"query":"from 'sample.zng' | _path==\"dns\" // foo | { i: count(), v: this} \n      | i > 0 \n      | head 500\n      | yield v"}{"query":"from 'sample.zng' | _path==\"dns\" // foo | { i: count(), v: this} \n      | i > 0 \n      | head 500\n      | yield v"}{"query":"from 'sample.zng' | _path==\"dns\" // foo | { i: count(), v: this} \n      | i > 0 \n      | head 500\n      | yield v"}

Indeed, if we hit the API directly, we see it fail similarly.

$ cat app-query.json 
{"query":"from 'sample.zng' | _path==\"dns\" // foo | { i: count(), v: this} \n      | i > 0 \n      | head 500\n      | yield v"}

$ curl http://localhost:9867/version
{"version":"v1.2.0-8-gd10050fe"}

$ curl -X POST -H 'Accept: application/x-zson' -H 'Content-Type: application/json' http://localhost:9867/query -d @app-query.json
[no response]

However, if we remove the \n newlines from the query, it starts working.

$ cat no-newlines.json 
{"query":"from 'sample.zng' | _path==\"dns\" // foo | { i: count(), v: this} | i > 0 | head 500 | yield v"}

$ curl -X POST -H 'Accept: application/x-zson' -H 'Content-Type: application/json' http://localhost:9867/query -d @no-newlines.json
{_path:"dns",ts:2020-02-25T16:03:13.978298Z,uid:"CMaGrB3IcMZluOA1Pc",id:{orig_h:192.168.1.110,orig_p:51848(port=uint16),resp_h:192.168.1.254,resp_p:53(port)},proto:"udp"(=zenum),trans_id:47856(uint64),rtt:16.907ms,query:"news.ycombinator.com",qclass:1(uint64),qclass_name:"C_INTERNET",qtype:1(uint64),qtype_name:"A",rcode:0(uint64),rcode_name:"NOERROR",AA:false,TC:false,RD:true,RA:true,Z:0(uint64),answers:["209.216.230.240"],TTLs:[35s],rejected:false}
{_path:"dns",ts:2020-02-25T16:03:11.27555Z,uid:"CzIQJS3vVEyBAg8gw9",id:{orig_h:192.168.1.110,orig_p:54375(port=uint16),resp_h:192.168.1.254,resp_p:53(port)},proto:"udp"(=zenum),trans_id:28084(uint64),rtt:17.946ms,query:"11.client-channel.google.com",qclass:1(uint64),qclass_name:"C_INTERNET",qtype:1(uint64),qtype_name:"A",rcode:0(uint64),rcode_name:"NOERROR",AA:false,TC:false,RD:true,RA:true,Z:0(uint64),answers:["173.194.201.189"],TTLs:[3m33s],rejected:false}

In conclusion, I assume the backend is treating the post-\n Zed as "live code" again, which is filtering the results out to nothing.

philrz avatar Jul 20 '22 19:07 philrz