← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~vaishnavi-asawale/launchpad:fix-binary-build-webhooks into launchpad:master

 

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

Commit message:
Modify binary build status webhook payload

Attaching build.log directly to the payload of the binary build status
webhook leads to a TypeError as the LibraryFileAlias is not JSON serializable.
This is chnaged to a canonical_url instead.
Additionally, if the log does not exist, None is returned in the payload.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~vaishnavi-asawale/launchpad/+git/launchpad/+merge/494967
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~vaishnavi-asawale/launchpad:fix-binary-build-webhooks into launchpad:master.
diff --git a/lib/lp/services/webhooks/interfaces.py b/lib/lp/services/webhooks/interfaces.py
index 26e1fa7..e922075 100644
--- a/lib/lp/services/webhooks/interfaces.py
+++ b/lib/lp/services/webhooks/interfaces.py
@@ -78,12 +78,12 @@ WEBHOOK_EVENT_TYPES = {
     "archive:binary-build:0.1::fullybuilt": "Binary build fully built",
     "archive:binary-build:0.1::failedtobuild": "Binary build failed to build",
     "archive:binary-build:0.1::chrootwait": "Binary build failed due"
-    "to chroot problem",
+    " to chroot problem",
     "archive:binary-build:0.1::cancelled": "Binary build cancelled",
     "archive:binary-build:0.1::failedtoupload": "Binary build failed"
-    "to upload",
+    " to upload",
     "archive:binary-build:0.1::superseded": "Binary build for"
-    "superseded source",
+    " superseded source",
 }
 
 
diff --git a/lib/lp/soyuz/subscribers/archive.py b/lib/lp/soyuz/subscribers/archive.py
index f8eb643..5eaa2d0 100644
--- a/lib/lp/soyuz/subscribers/archive.py
+++ b/lib/lp/soyuz/subscribers/archive.py
@@ -46,8 +46,11 @@ def _trigger_build_status_change_webhook(build, event_type):
             ),
         }
 
-        if getattr(build, "log", None):
-            payload["buildlog"] = build.log
+        payload["buildlog"] = (
+            canonical_url(build.log, force_local_path=True)
+            if getattr(build, "log", None)
+            else None
+        )
 
         getUtility(IWebhookSet).trigger(build.archive, event_type, payload)
 

Follow ups