Skip to content

Search API scoped to blobs does not honor per_page

Summary

Using the Groups Search API scoped to Blobs, the per_page parameter is not honored in the number of results returned, but is "honored" in the X-* headers.

Steps to reproduce

  • Run a query using the Groups Search API scoped to blobs with a per_page parameter such as https://gitlab.com/api/v4/groups/<some group id>/search?scope=blobs&search=<some value> extension:yml&per_page=100
  • Examine the headers returned and the number of results actually returned in the body. Results will always be 20. Headers will be computed based on the per_page setting
  • Note: Setting the &page= value in the query string also seems to be properly "scoped" to 20, regardless of per_page

Example Project

Don't think it's project-specific. I will call out that this was on an Advance Global Search enabled group on gitlab.com

What is the current bug behavior?

  • Only 20 results are returned, regardless of the per_page setting
  • The headers X-Total, X-Total-Pages, X-Per-Page are all calculated, properly, based on the per_page parameter
  • &page= parameter in the query string is always relative to per_page of 20

What is the expected correct behavior?

Either:

  • Respect the per_page setting as expected

Or:

  • Make sure headers match the default of 20 and that we aren't doing any extra processing around per_page needlessly
  • Make sure to update the documentation for the Search API to call out this limitation

Potentially Related

Edited by Kai Armstrong