Task copycollectionitems should catch ItemAdditionError and report the error back
With users playing with package repositories, they are sometimes hitting the restrictions applied to debian:suite collections and when that's the case the admins get mails due to an unhandled exception:
Exception in Task copycollectionitems
ItemAdditionError
New source version 2.32.60+ds-3~2+2+g18e3c0e < existing version 2.32.60+ds-3~2+2+gff2f9c8
(Note that this one lacks the package name and the collection id to be useful)
Exception in Task copycollectionitems
ItemAdditionError
duplicate key value violates unique constraint "db_collectionitem_unique_active_name"
DETAIL: Key (name, parent_collection_id)=(kothic_0.0~git20231126.2796db7-2, 2171) already
exists.
[...]
File "/usr/lib/python3/dist-packages/debusine/tasks/_task.py", line 552, in
execute_logging_exceptions
return self.execute()
^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/debusine/server/tasks/base.py", line 74, in execute
return super().execute()
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/debusine/tasks/_task.py", line 565, in execute
result = self._execute()
^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/debusine/server/tasks/copy_collection_items.py", line 235, in _execute
self.copy_item(
^
File "/usr/lib/python3/dist-packages/debusine/server/tasks/copy_collection_items.py", line 194, in copy_item
target_collection.manager.add_artifact(
^
File "/usr/lib/python3/dist-packages/debusine/server/collections/base.py", line 208, in add_artifact
return self.do_add_artifact(
File "/usr/lib/python3/dist-packages/debusine/server/collections/debian_suite.py", line 317, in do_add_artifact
raise ItemAdditionError(str(exc))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I did not take the time to find out the copycollectionitems task that failed, but I assume that the error is unlikely to be shown back to the user if it's not caught (except by the "mail_admins" handler).
Edited by Raphaël Hertzog