← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:fix-snap-base-build-channels-by-arch into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:fix-snap-base-build-channels-by-arch into launchpad:master.

Commit message:
Fix Snap.requestBuildsFromJob to handle channels=None again

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/407176

In https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/407094, I overlooked the fact that `Snap._pickChannels` can return None.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-snap-base-build-channels-by-arch into launchpad:master.
diff --git a/lib/lp/snappy/model/snap.py b/lib/lp/snappy/model/snap.py
index 4eaa4ee..24aa2be 100644
--- a/lib/lp/snappy/model/snap.py
+++ b/lib/lp/snappy/model/snap.py
@@ -892,7 +892,10 @@ class Snap(Storm, WebhookTargetMixin):
             snap_base, snap_base_name = self._findBase(snapcraft_data)
             distro_series = self._pickDistroSeries(snap_base, snap_base_name)
             channels = self._pickChannels(snap_base, channels=channels)
-            channels_by_arch = channels.pop("_byarch", {})
+            if channels is not None:
+                channels_by_arch = channels.pop("_byarch", {})
+            else:
+                channels_by_arch = {}
 
             # Sort by Processor.id for determinism.  This is chosen to be
             # the same order as in BinaryPackageBuildSet.createForSource, to
@@ -916,9 +919,12 @@ class Snap(Storm, WebhookTargetMixin):
         builds = []
         for build_instance in architectures_to_build:
             arch = build_instance.architecture
-            arch_channels = dict(channels)
-            if arch in channels_by_arch:
-                arch_channels.update(channels_by_arch[arch])
+            if channels is not None:
+                arch_channels = dict(channels)
+                if arch in channels_by_arch:
+                    arch_channels.update(channels_by_arch[arch])
+            else:
+                arch_channels = None
             try:
                 build = self.requestBuild(
                     requester, archive, supported_arches[arch], pocket,