Skip to content

Fix Search API project scope

Dmitry Gruzd requested to merge 347238-fix-api-project-search into master

What does this MR do and why?

This MR fixes NoMethodError: undefined method '+' for nil:NilClass when using search API with projects scope and empty search term. It turned out that the problem is in Elastic::Latest::ProjectClassProxy.

https://sentry.gitlab.net/gitlab/gitlabcom/issues/2922037/?query=correlation_id%3A%2201FP85W5PWF1WH6XET36AB10H9%22

#347238 (closed)

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

  1. Enable Advanced Search if it's not configured
  2. Checkout the master branch
  3. Execute this command in rails console:
    Search::GlobalService.new(nil, { scope: 'projects', search: '' }).execute.objects('projects')
  4. Ensure that it fails with the NoMethodError exception
  5. Checkout this MR's branch
    git checkout 347238-fix-api-project-search
  6. Execute the same command in rails console:
    Search::GlobalService.new(nil, { scope: 'projects', search: '' }).execute.objects('projects')
  7. This time it should return results

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #347238 (closed)

Edited by Dmitry Gruzd

Merge request reports

Loading