launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29334
[Merge] ~apw/launchpad:archive-removeCopyNotification-fixes into launchpad:master
Andy Whitcroft has proposed merging ~apw/launchpad:archive-removeCopyNotification-fixes into launchpad:master.
Commit message:
removeCopyNotification: error handling fixes
Handle invalid and already acknowledged errors more cleanly reporting NotFound and Gone errors respectively.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1993523 in Launchpad itself: "removeCopyNotification errors are all reported as ServerErrors"
https://bugs.launchpad.net/launchpad/+bug/1993523
For more details, see:
https://code.launchpad.net/~apw/launchpad/+git/my/+merge/431805
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~apw/launchpad:archive-removeCopyNotification-fixes into launchpad:master.
diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py
index 61acec4..3a19341 100644
--- a/lib/lp/soyuz/model/archive.py
+++ b/lib/lp/soyuz/model/archive.py
@@ -45,6 +45,7 @@ from lp.app.errors import (
IncompatibleArchiveStatus,
IncompatibleArguments,
NotFoundError,
+ GoneError,
)
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
from lp.app.interfaces.security import IAuthorization
@@ -3076,7 +3077,7 @@ class Archive(SQLBase):
pcj = PlainPackageCopyJob.get(job_id)
job = pcj.job
if job.status != JobStatus.FAILED:
- raise AssertionError("Job is not failed")
+ raise GoneError("Job is not failed")
Store.of(pcj.context).remove(pcj.context)
job.destroySelf()
diff --git a/lib/lp/soyuz/model/packagecopyjob.py b/lib/lp/soyuz/model/packagecopyjob.py
index aee140f..fc91c93 100644
--- a/lib/lp/soyuz/model/packagecopyjob.py
+++ b/lib/lp/soyuz/model/packagecopyjob.py
@@ -189,7 +189,7 @@ class PackageCopyJobDerived(BaseRunnableJob, metaclass=EnumeratedSubclass):
its job_type does not match the desired subclass.
"""
job = IStore(PackageCopyJob).get(PackageCopyJob, job_id)
- if job.job_type != cls.class_job_type:
+ if job is None or job.job_type != cls.class_job_type:
raise NotFoundError(
"No object found with id %d and type %s"
% (job_id, cls.class_job_type.title)