Skip to content

Search: ensure zoekt client is always non-nil

Administrator requested to merge cc/always-zoekt-client into main

Created by: camdencheek

Currently, we check whether indexed search is enabled by checking whether the Zoekt client is nil. This is dangerous because then we're passing around a possibly-nil zoekt.Streamer, which will panic when its methods are called. This has bit us in the past.

This modifies search.Indexed() to always return a valid client, even if the index is disabled. The returned client will error when used, but will not panic.

In order to change behavior based on whether the index is enabled, conf.SearchIndexEnabled() should be used. Everywhere that was previously checking nilness of search.Indexed() has been updated to use conf.SearchIndexEnabled().

Stacked on #34292

Test plan

Manually tested that disabling the index does not cause panics for the modified code paths.

Merge request reports

Loading