Strapi: Count route responds 404 *only* when should return 0

Created on 26 Jun 2018  路  3Comments  路  Source: strapi/strapi

**Informations

  • Node.js version:Node v10.4.1
  • npm version: npm 6.1.0
  • Strapi version: 3.0.0-alpha.12.6
  • Database: 10.1.32-MariaDB (myqsl 5.6.36 / PHP 5.6.36 from XAMPP for OSX)
  • Operating system: mac os high sierra 10.13.4

What is the current behavior?

When I run a count request with filters, and the expected resoult is greater equal than 1, It responses is the correct number, but when should respond with a 0, I get a 404

Steps to reproduce the problem
Create some entity, fill some data, and run a count request with some filters

For example I have my invoice entity
screen shot 2018-06-26 at 11 24 26

With this data
screen shot 2018-06-26 at 11 24 15

The "found something count" works great
screen shot 2018-06-26 at 11 23 50

but the "should return 0" returns a 404
screen shot 2018-06-26 at 11 24 02

What is the expected behavior?
Is this a bug or a feature? When the count ammount is 0, I think it should return a 0, its more accurate than a 404

related with https://github.com/strapi/strapi/issues/1344 maybe?

good first issue medium confirmed bug

Most helpful comment

@guillermodoghel unlikely related to my issue there. The count service likely doesn't have a catch setup. Much like a GET request returns an empty json array, the count doesn't get a response from the db on data and defaults to a 404 error.

Your right that it should return a 0. (Technically speaking this should be a 500 error if anything lol, 4xx is a user problem. So regardless it shouldn't be a 404)

I can confirm this bug exists though.

All 3 comments

@guillermodoghel unlikely related to my issue there. The count service likely doesn't have a catch setup. Much like a GET request returns an empty json array, the count doesn't get a response from the db on data and defaults to a 404 error.

Your right that it should return a 0. (Technically speaking this should be a 500 error if anything lol, 4xx is a user problem. So regardless it shouldn't be a 404)

I can confirm this bug exists though.

There is somewhere (haha) in the code where we check if the body is empty or not to set 404 response. We have to omit 0 as body to not send 404 response.
The thing you have to do is to find where the test is made :shipit:

@lauriejim are you working on this? I could have a look and raise a PR later today if you haven't started yet. 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhoub picture zhoub  路  3Comments

quibaritaenperdresatrompe picture quibaritaenperdresatrompe  路  3Comments

dufoli picture dufoli  路  3Comments

doublemarked picture doublemarked  路  3Comments

GreenGremlin picture GreenGremlin  路  3Comments