Skip to content

Commit

Permalink
Merge pull request #8148 from EricSoroos/search_rebuild_message
Browse files Browse the repository at this point in the history
Add an error notification when rebuilding the search index for a package that can't be found
  • Loading branch information
wardi committed Apr 4, 2024
2 parents 7ca456d + 84bb65f commit c634d42
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions changes/8148.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add error notification when rebuilding the search index via the cli when the requested package can't be found.
2 changes: 2 additions & 0 deletions ckan/cli/search_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def rebuild(
defer_commit=(not commit_each),
quiet=quiet and not verbose,
clear=clear)
except logic.NotFound:
error_shout("Couldn't find package %s" % package_id)
except Exception as e:
error_shout(e)
if not commit_each:
Expand Down
6 changes: 6 additions & 0 deletions ckan/tests/cli/test_search_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,9 @@ def test_test_main_operations(self, cli):
assert not result.exit_code, result.output
search_result = helpers.call_action(u'package_search', q=u"package")
assert search_result[u'count'] == 2

def test_rebuild_invalid_dataset(self, cli):
# attempt to index package that doesn't exist
result = cli.invoke(ckan, [u'search-index', u'rebuild', u'invalid-dataset'])
assert not result.exit_code, result.output
assert "Couldn't find" in result.output

0 comments on commit c634d42

Please sign in to comment.