Skip to content

Fix empty JSON API responses

Nick Thomas requested to merge fix-json-api-empty-responses into master

What does this MR do?

In gitlab-workhorse!510 (comment 350220349) we learned that the Grape API sends a HTTP response with Content-Length: 4 and the body null if you don't give it an explicit body.

This is particularly the case for responses that expect workhorse to handle the response body, but I fixed every case I saw.

We're using this feature of grape: https://github.com/ruby-grape/grape/pull/850

It doesn't let us send a 200 application/json response with an empty body. The current approach sends a 204 No Content instead. We could switch to text/plain to allow the 200 instead. I'll see what tests fail (if any) and make a decision on what makes most sense.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Merge request reports