Skip to content

Commit

Permalink
Add yet another potential error message.
Browse files Browse the repository at this point in the history
Because we support so many 'versions' of Solr, we're encountering
different error messages as the only way of determining what went wrong.
In some cases the response is HTML :(

To fix this we explicitly check in the test if it succeeded (we get a
200 when we get an error response) and inform the dev where to go to add
their newly discovered error message.
  • Loading branch information
rossjones committed Feb 19, 2016
1 parent 77127bc commit 99a1c2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ckan/lib/search/query.py
Expand Up @@ -362,7 +362,9 @@ def run(self, query):
# Error with the sort parameter. You see slightly different
# error messages depending on whether the SOLR JSON comes back
# or Jetty gets in the way converting it to HTML - not sure why
#
if "Can't determine a Sort Order" in e.body or \
"Can't determine Sort Order" in e.body or \
'Unknown sort order' in e.body:
raise SearchQueryError('Invalid "sort" parameter')
raise SearchError(
Expand Down
8 changes: 7 additions & 1 deletion ckan/tests/controllers/test_package.py
Expand Up @@ -758,7 +758,13 @@ def test_search_sort_by_bad(self):
offset = url_for(controller='package', action='search') + \
'?sort=gvgyr_fgevat+nfp'
app = self._get_test_app()
app.get(offset, status=400)
response = app.get(offset, status=[200, 400])
if response.status == 200:
import sys
sys.stdout.write(response.body)
raise Exception("Solr returned an unknown error message. "
"Please check the error handling "
"in ckan/lib/search/query.py:run")

def test_search_solr_syntax_error(self):
factories.Dataset()
Expand Down

0 comments on commit 99a1c2f

Please sign in to comment.