Heello / Issues

Bug and feature tracking
1 stars 0 forks source link

endpoint /pings/create returns 500, though posts successfully #1

Closed katanacrimson closed 11 years ago

katanacrimson commented 11 years ago

Problem observed during node-heello unit tests.

Related test code:

    describe('pings endpoints -', function() {
        it('POST /pings/create (heello.pings.create)', function(done) {
            heello.pings.create({
                'ping[text]':'node-heello test ping'
            }, function(err, res) {
                assert.ifError(err, 'request error')
                assert.equal(res.status, 201, 'request error')
            })
        })
    })

Result:

  × 1 of 32 tests failed:

  1) node-heello Authenticated REST API - pings endpoints - POST /pings/create (heello.pings.create):
     Error: got 500 response

Ping created with the 500 response being returned: https://heello.com/katana/9020290

caseym commented 11 years ago

Please post the full request and response. Here is a request and response for: https://heello.com/heello_dev/9033140

curl -i -d "ping[text]=Testing Ping API via curl" -d "access_token=MY_ACCESS_TOKEN" -X POST "https://api.heello.com/pings.json" HTTP/1.1 201 Created Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Thu, 18 Apr 2013 17:10:39 GMT ETag: "4732bf722fde9b1f474c385d7378c3bd" Server: nginx/1.2.4 Set-Cookie: makara-force-master=master; expires=Thu, 18-Apr-2013 17:10:44 GMT Status: 201 Created X-Rack-Cache: invalidate, pass X-RateLimit-Limit: 8400 X-RateLimit-Remaining: 8360 X-Request-Id: 83cd44fad9a666a3cf08de0129cc4f16 X-Runtime: 0.036230 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 721 Connection: keep-alive

{"response":{"id":9033140,"text":"Testing Ping API via curl","user_id":1705160,"echo_id":null,"reply_id":null,"checkin":false,"created_at":"2013-04-18T17:10:39Z","user":{"id":1705160,"username":"heello_dev","name":"Heello Developer","bio":null,"website":null,"location":null,"timezone":null,"created_at":"2013-01-10T20:28:57Z","avatar":"//d2trw7474qpa0b.cloudfront.net/default.png","background":"//d2dh8keolssd5w.cloudfront.net/default.png","cover":"//d38xdbig8ajh16.cloudfront.net/default.png","metadata":{"ping_count":2,"checkin_count":0,"listener_count":1,"listening_count":0}},"media":{},"metadata":{"echo_count":0,"reply_count":0,"can_reply":true,"can_delete":true,"can_echo":false,"is_private":false},"replies":[]}}

katanacrimson commented 11 years ago
POST /pings/ HTTP/1.1
Host: api.heello.com
Accept-Encoding: gzip, deflate
Accept: application/vnd.heello.v1
User-Agent: node-heello_v0.0.2
Content-Type: application/x-www-form-urlencoded
Content-Length: 118
Connection: keep-alive

ping%5Btext%5D=node-heello%20test%20ping&access_token=[redacted]

Response data:

response headers:
   { 'content-type': 'text/html; charset=utf-8',
     date: 'Thu, 18 Apr 2013 20:48:20 GMT',
     server: 'nginx/1.2.4',
     status: '500 Internal Server Error',
     'x-rack-cache': 'invalidate, pass',
     'x-ratelimit-limit': '8400',
     'x-ratelimit-remaining': '8392',
     'x-request-id': 'eda019f429bd70dd644f3375a2822349',
     'x-runtime': '0.030550',
     'content-length': '643',
     connection: 'keep-alive' },

body:

<!DOCTYPE html>\n<html>\n<head>\n  <title>We\'re sorry, but something went wrong (500)</title>\n  <style type="text/css">\n    body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }\n    div.dialog {\n      width: 25em;\n      padding: 0 4em;\n      margin: 4em auto 0 auto;\n      border: 1px solid #ccc;\n      border-right-color: #999;\n      border-bottom-color: #999;\n    }\n    h1 { font-size: 100%; color: #f00; line-height: 1.5em; }\n  </style>\n</head>\n\n<body>\n  <!-- This file lives in public/500.html -->\n  <div class="dialog">\n    <h1>We\'re sorry, but something went wrong.</h1>\n  </div>\n</body>\n</html>\n

Will the x-request-id help with loghunting on your side? I'm wondering if that'll help find the root cause.

caseym commented 11 years ago

The issue is that the POST url didn't contain the response format (i.e. POST /pings.json)

The documentation was lacking in this respect and has been updated accordingly to show the presence of the format requirement on the POST url.

katanacrimson commented 11 years ago

Odd. Will correct this and retest node-heello to verify. There does seem to be something of issue though - why was it still creating a ping even without the response format?

caseym commented 11 years ago

The error happened when we were preparing the response. Basically, we created the Ping, then tried to respond with the newly created Ping. When creating the response, we couldn't determine which format to put it in and errored out.

katanacrimson commented 11 years ago

Ahh, makes sense. Hmm, maybe that should be a transaction, and rolled back when the format couldn't be determined? Or default to one format?

In any case, I'm slightly modifying this to try and get it to cooperate. heello.pings.create test seems to be passing now. I do notice another strange bug with the timeline now though on the web app, but that's something I'll post in a separate issue - seems related to ping deletion.

katanacrimson commented 11 years ago

Here's another endpoint which is lacking the .json in the documentation.

https://developer.heello.com/docs/1/PUT/accounts/update