From 437b728a9f138f5109227b027474a3c26fc7f81f Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Tue, 19 Apr 2016 17:28:42 +0100 Subject: bitbake: toaster: prevent exception when Project.release is null Project.release can be null. This causes an exception when calling get_all_compatible_layer_versions(), as the query to fetch the layer versions references release.branch_name. Add a guard to the function so that an empty queryset is returned if the release isn't set for a project. (Bitbake rev: 6919a2b2e412a9e7b652a6bc191e7c1bed035222) Signed-off-by: Elliot Smith Signed-off-by: Michael Wood Signed-off-by: Richard Purdie --- bitbake/lib/toaster/orm/models.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'bitbake') diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 68c3072991..f0a8786640 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -264,11 +264,17 @@ class Project(models.Model): def get_all_compatible_layer_versions(self): """ Returns Queryset of all Layer_Versions which are compatible with this project""" - queryset = Layer_Version.objects.filter( - (Q(up_branch__name=self.release.branch_name) & - Q(build=None) & - Q(project=None)) | - Q(project=self)) + queryset = None + + # guard on release, as it can be null + if self.release: + queryset = Layer_Version.objects.filter( + (Q(up_branch__name=self.release.branch_name) & + Q(build=None) & + Q(project=None)) | + Q(project=self)) + else: + queryset = Layer_Version.objects.none() return queryset -- cgit v1.2.3-54-g00ecf