handling non HTTP 200 statuses

42 views
Skip to first unread message

Rajarshi Guha

unread,
Jun 8, 2013, 12:34:20 PM6/8/13
to ql...@googlegroups.com
Hi, I just discovered this project and it looks pretty cool. I was playing with it on some internal APIs and it seems that the processing chain stops when it gets a HTTP 404 or 500 for one of the calls in a multi-item query.

For example

create table targets on select get from 'http://foo/{^bid}';
return select * from targets where bid in (84, 64);

works fine and returns a 2-element response but 

create table targets on select get from 'http://foo/{^bid}';
return select * from targets where bid in (84, 64, 12345);

gives no response. In this query, the last id (12345) leads to a HTTP 404, even though the first two work fine.

Is this a feature? Or is there a way to indicate that a HTTP 404 (or 500 etc) should be treated the same as an empty response?

Thanks,
Rajarshi

Jason Xie

unread,
Jun 11, 2013, 2:05:06 PM6/11/13
to ql...@googlegroups.com
Hi Rajarshi,

What your described is the expected behavior.

If you attempt to override, please refer to http://ql.io/docs/monkey-patch. Specifically, you may explore how the 'patch status' and 'patch response' may alter the HTTP 404 response. thanks!

jason

Rajarshi Guha

unread,
Jun 11, 2013, 10:26:50 PM6/11/13
to ql...@googlegroups.com
Hi Jason, thanks for the pointer. I was hoping you could clarify a few things:

I need to patch the status (change it from a 500 to a 200) as well as patch the response (change a HTML response to an empty JSON response). I have the following code in a JS file:

exports['patch response'] = function(args) {
    var status = args.status;
    if (status == 500) {
        log('info', 'Got HTTP 500 '+args.body);
        return {
            status: 200,
            type: 'application/json',
                content: JSON.stringify({})
                };
    }
}

However this doesn't seem to be doing anything - is there a way to debug monkey patches?

Also, where does the log message go?

Thanks,



--
You received this message because you are subscribed to a topic in the Google Groups "ql.io" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qlio/HYP-j3rchwM/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to qlio+uns...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Rajarshi Guha | http://blog.rguha.net
NIH Center for Advancing Translational Science

Jason Xie

unread,
Jun 12, 2013, 3:06:55 PM6/12/13
to ql...@googlegroups.com, rajars...@gmail.com
Hi Rajarshi,

your monkey patch .js file needs to be in a certain directory as instructed at http://ql.io/docs/monkey-patch

As for the log. use args.log , and it should be captured in the same log file as the ql.io engine on the filesystem. Thanks!

jason
Reply all
Reply to author
Forward
0 new messages