storyblok / storyblok

Info about Storyblok
https://storyblok.atlassian.net/servicedesk
318 stars 32 forks source link

Response's `total` header is always 1 when `search_term` param is used #660

Closed joshgamache closed 3 years ago

joshgamache commented 3 years ago

The issue occurs while working with: (check one with "x")

Current behavior:

When making a request to the Content Delivery API with a search_term= param, the resulting total header returns as 1 even when multiple stories objects are returned with the response.

Expected behavior:

Header total should show the number of results from the search_term=

Steps to reproduce:

Used Postman to test, but got the same results using Chrome dev tools and from within a nodeJS application. Generated a new API token for testing.

  1. Go to https://api.storyblok.com/v1/cdn/stories?token=CdTBbLaOI1hAdvaeYbfmGgtt and check response headers. Total is a number > 1. (1014 as of this report).
  2. Go to https://api.storyblok.com/v1/cdn/stories?token=CdTBbLaOI1hAdvaeYbfmGgtt&search_term=the and check response headers. Total is 1, despite multiple stories objects returned.

Other information:

Tested this with many other params (starts_with, per_page, resolve_relations, sort_by), within the JS client, and even with the GraphQL API. None of these had an impact on the total. Initially, the problem cropped up when trying get a max number for pagination. I'm not sure if I can trust my memory, but I feel like the total from a search term had previously worked as expected above.

onefriendaday commented 3 years ago

Thanks for the report! We found the problem and will release an hotfix today.

onefriendaday commented 3 years ago

Has been fixed https://api.storyblok.com/v1/cdn/stories?token=CdTBbLaOI1hAdvaeYbfmGgtt&search_term=the&cv=1

cronin4392 commented 3 years ago

I appear to be running into this issue as well except on the storyblok-js-client side of things.

https://github.com/storyblok/storyblok-js-client/issues/106

ChristopheCorbalan commented 3 years ago

Same here.

jakubzajac commented 3 years ago

Same issue here. Seems to work when using v1 of the API.