ql.io returns 400 instead of 401

101 views
Skip to first unread message

Satish

unread,
Dec 5, 2012, 4:31:07 AM12/5/12
to ql...@googlegroups.com, nikhil....@gmail.com
I created a simple table that consumes AppNexus api's and gets list of all publishers
>>
        create table MyAN_getAllPublishers
           on select get from "http://sand.api.appnexus.com/publisher"
            using headers 'Authorization'='{token}';
          
        select * from MyAN_getAllPublishers
            where token=lfatvle7t8mi1er50j4s2027u0;

AppNexus requires token for each api call in header as i have done in create table.
Now when i query with correct token then it gives me the correct output.

When i use token which is expired, then the appnexus site give 401 as HTTP status code and response giving details.
But ql.io gives me 400 Bad Request as HTTP status code and response embedded in body record along with some header record and "emitted": true.

Response from AppNexus:

{
    "response" :
    {
        "error_id" : "NOAUTH",
        "error" : "Authentication failed - not logged in",
        "error_description" : null,
        "service" : null,
        "method" : null,
        "error_code" : null,
        "dbg_info" :
        {
            "instance" : "09.hbapi.sand-08.ams1",
            "slave_hit" : false,
            "db" : "master",
            "awesomesauce_cache_used" : false,
            "warnings" : [],
            "time" : 25.92921257019,
            "start_microtime" : 1354697253.6361,
            "version" : "1.13.4.3"
        }
    }
}


Response from ql.io
{
  • "headers": {
    • "content-type": "application/json"
    },
  • "body": {
    • "response": {
      • "error_id": "NOAUTH",
      • "error": "Authentication failed - not logged in",
      • "error_description": null,
      • "service": null,
      • "method": null,
      • "error_code": null,
      • "dbg_info": {}
      }
    },
  • "emitted": true
}

Although i can see status response of 401 from AppNexus in Req/resp traces.

Any help will be deeply appreciated.

PFA: Screenshot of ql.io along with Req/resp traces

qlio_error.jpg

shimonchayim

unread,
Dec 5, 2012, 1:25:28 PM12/5/12
to ql...@googlegroups.com, nikhil....@gmail.com
I suggest you may want to create a curl request that works and then make the necessary changes to the table. From the response it just seems like the request did go the server. The Har viewer (where the payload is showing up) can also show the headers sent and received. You may want to double check that also.

shimonchayim

unread,
Dec 5, 2012, 1:32:44 PM12/5/12
to ql...@googlegroups.com, nikhil....@gmail.com
Satish, I might have replied too soon. We don't propagate the status code by default. But you are able to override the status using monkey patch.

Check 'patch status' monkey patch here: http://ql.io/docs/monkey-patch

Satish

unread,
Dec 6, 2012, 3:28:18 AM12/6/12
to ql...@googlegroups.com, nikhil....@gmail.com
Thanks shimonchayim for quick response.

As suggested, I added the patch to status as below:

exports['patch status'] = function(args) {
    var retCode = args.status;
    return retCode;
}

But it still shows 400 for 401 response code from AppNexus.

Then i tried returning hard-coded status code from patch as:

exports['patch status'] = function(args) {
    return 200;
}

But it seems like ql.io supports only 200 and 400 as response codes.
All other values are either mapped to 400 or 200.

Please let me if i have done anything wrong or is there another way to it.

P.S.: Patch is working since i tried with returning hard-coded status 200 and ql.io returned 200 even for 401 from target.

Regards,
Satish
Reply all
Reply to author
Forward
0 new messages