UnboundLocalError when calling SearchCorpus while Solr is offline

Erwan Rouchet
2025-11-26T13:33:57Z

1. Shut down Solr, or set solr.api_url to a URL that doesn't exist in the backend settings

2. Attempt to search on any indexable corpus

3. Traceback (most recent call last):
(...)
File ".../arkindex/documents/api/search.py", line 168, in get
    nb_results = results.get_num_found()
UnboundLocalError: local variable 'results' referenced before assignment

4. Cry.

This should raise the error from Solr instead, which would at least show something that makes more sense to admins.