question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parse Error on DELETE with 204 Response and empty body

See original GitHub issue

I’m uncertain if this is related to #196

I have a couple DELETE methods defined similar to the following in my API Blueprint:

### Delete a Type [DELETE /types/{type}]

+ Parameters
    + type: 1 (number, required)
        id of type to fetch

+ Response 204

but when I run the tests everything passes except the DELETEs, each shows a similar result to this:

pass: POST /types duration: NaNms
pass: GET /types?limit=20&skip=0&order=name duration: NaNms
pass: GET /types/1?limit=20&skip=0&order=name duration: NaNms
pass: PUT /types/1 duration: NaNms
error: DELETE /types/1 duration: 82ms
error: Error: Parse Error
  at Error (native)
  at Socket.socketOnData (_http_client.js:305:20)
  at emitOne (events.js:77:13)
  at Socket.emit (events.js:169:7)
  at readableAddChunk (_stream_readable.js:146:16)
  at Socket.Readable.push (_stream_readable.js:110:10)
  at TCP.onread (net.js:523:20)

< ... additional tests run... >

info: Displaying failed tests...
fail: DELETE /types/1 duration: 82ms
fail: 
request: 
body: 

headers: 
    User-Agent: Dredd/1.0.10 (Linux 3.19.0-25-generic; x64)

uri: /types/1
method: DELETE


expected: 
headers: 

body: 

statusCode: 204


actual: 
statusCode: 204
headers: 
    server: nginx/1.8.0
    content-type: text/html; charset=UTF-8
    connection: close
    cache-control: no-cache
    date: Wed, 04 May 2016 06:20:39 GMT

body: 





This looks to me like the actual matches the expected (unless the content-type is throwing it off?) so what gives here.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
galenandrewcommented, May 23, 2016

@honzajavorek is this a bug with dredd or gavel? If you point me in the right direction, I’d be happy to take a stab at a PR.

1reaction
honzajavorekcommented, May 10, 2016

Thanks for reporting this! It looks like Dredd is trying to parse the empty body as JSON and fails, although there’s no content type specified. It’s definitely a bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parse Error when empty body on PUT with 204 response - Help
Parse Error when empty body on PUT with 204 response ... When a PUT request returns a HTTP 204 code, it usually don't...
Read more >
c# - How to return HTTP 204 response on successful DELETE ...
The first time it works perfectly, but a repeated call will cause Fiddler to throw an error stating last response wasn't formed properly....
Read more >
Return empty body for 204 responses in API (!22086) - GitLab
An error occurred while fetching the assigned milestone of the selected merge_request. Return empty body for 204 responses in API.
Read more >
Delete with REST.. 200 or 204 response code? - LinkedIn
I personally like to return 204 if the delete is successful at server. In you example of employe termination, you are actually not...
Read more >
Error Responses - Amazon Simple Storage Service
Error Code Description HTTP Status Code AccessControlListNotSupported The bucket does not allow ACLs. 400 Bad Request AccessDenied Access Denied 403 Forbidden BucketAlreadyOwnedByYou 409 Conflict (in all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found