← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~vaishnavi-asawale/launchpad:fix-source-upload-webhooks into launchpad:master

 

Vaishnavi Asawale has proposed merging ~vaishnavi-asawale/launchpad:fix-source-upload-webhooks into launchpad:master.

Commit message:
Ensure event.edited_fields exists in source package webhook handler
    
This MP fixes the tests broken by
https://code.launchpad.net/~vaishnavi-asawale/launchpad/+git/launchpad/+merge/494750
in which, as a final step, the lazr.restful layer triggers the ObjectModifiedEvent
with a security-proxied PackageUpload object that has no edited_fields in the
modified event, causing the test to break at the handler function wich checks
the existence of 'status' in the edited fields.
    
This is fixed by first ensuring that event.edited_fields exists.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~vaishnavi-asawale/launchpad/+git/launchpad/+merge/494890
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~vaishnavi-asawale/launchpad:fix-source-upload-webhooks into launchpad:master.
diff --git a/lib/lp/soyuz/subscribers/archive.py b/lib/lp/soyuz/subscribers/archive.py
index 9faf2b6..b7d2e77 100644
--- a/lib/lp/soyuz/subscribers/archive.py
+++ b/lib/lp/soyuz/subscribers/archive.py
@@ -45,10 +45,14 @@ def package_status_change_webhook(upload, event):
     # there are instances of rejected source package uploads which do not have
     # any sources
     if not upload.builds:
-        if "status" in event.edited_fields and (
-            upload.status == PackageUploadStatus.ACCEPTED
-            or upload.status == PackageUploadStatus.REJECTED
-            or upload.status == PackageUploadStatus.UNAPPROVED
+        if (
+            event.edited_fields
+            and "status" in event.edited_fields
+            and (
+                upload.status == PackageUploadStatus.ACCEPTED
+                or upload.status == PackageUploadStatus.REJECTED
+                or upload.status == PackageUploadStatus.UNAPPROVED
+            )
         ):
             _trigger_source_package_status_change_webhook(
                 upload,

Follow ups