From 7854506cd033f6f80c47de60cc9e582488cc26d6 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Wed, 3 Apr 2024 16:25:42 +0200 Subject: [PATCH 1/3] Add an error notification when rebuilding the search index for a package that can't be found --- ckan/cli/search_index.py | 2 ++ ckan/tests/cli/test_search_index.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/ckan/cli/search_index.py b/ckan/cli/search_index.py index cacde57b9df..7782dc221b9 100644 --- a/ckan/cli/search_index.py +++ b/ckan/cli/search_index.py @@ -48,6 +48,8 @@ def rebuild( defer_commit=(not commit_each), quiet=quiet and not verbose, clear=clear) + except logic.NotFound as e: + error_shout("Couldn't find package %s" % package_id) except Exception as e: error_shout(e) if not commit_each: diff --git a/ckan/tests/cli/test_search_index.py b/ckan/tests/cli/test_search_index.py index 863b2af6e97..1b6f930ecb3 100644 --- a/ckan/tests/cli/test_search_index.py +++ b/ckan/tests/cli/test_search_index.py @@ -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 From a1e53d3a104f25b2265a69728b2aa0330819dc82 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Thu, 4 Apr 2024 10:11:27 +0200 Subject: [PATCH 2/3] lint --- ckan/cli/search_index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckan/cli/search_index.py b/ckan/cli/search_index.py index 7782dc221b9..fbf134f327d 100644 --- a/ckan/cli/search_index.py +++ b/ckan/cli/search_index.py @@ -48,7 +48,7 @@ def rebuild( defer_commit=(not commit_each), quiet=quiet and not verbose, clear=clear) - except logic.NotFound as e: + except logic.NotFound: error_shout("Couldn't find package %s" % package_id) except Exception as e: error_shout(e) From 84bb65fa085a3635367c126e7c529746cbba1b59 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Thu, 4 Apr 2024 10:11:37 +0200 Subject: [PATCH 3/3] changelog --- changes/8148.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/8148.bugfix diff --git a/changes/8148.bugfix b/changes/8148.bugfix new file mode 100644 index 00000000000..e1b5a8c5c77 --- /dev/null +++ b/changes/8148.bugfix @@ -0,0 +1 @@ +Add error notification when rebuilding the search index via the cli when the requested package can't be found.