From eae151ff96c21794f2c967393d55d2cc05be24ca Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 4 Apr 2017 13:41:38 -0400 Subject: [PATCH] Allow null avatars from Gitlab Not all gitlab repositories have defined owners, meaning we cannot always get an avatar_url for the namespace Fixes https://sentry.io/coreos/backend-production/issues/241774339/ --- buildtrigger/basehandler.py | 2 +- buildtrigger/gitlabhandler.py | 3 ++- .../manage-trigger-githost.component.html | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/buildtrigger/basehandler.py b/buildtrigger/basehandler.py index f7491e97d..d0b621c80 100644 --- a/buildtrigger/basehandler.py +++ b/buildtrigger/basehandler.py @@ -21,7 +21,7 @@ NAMESPACES_SCHEMA = { 'description': 'Score of the relevance of the namespace', }, 'avatar_url': { - 'type': 'string', + 'type': ['string', 'null'], 'description': 'URL of the avatar for this namespace', }, 'url': { diff --git a/buildtrigger/gitlabhandler.py b/buildtrigger/gitlabhandler.py index f34d2ddd9..c5966c4f7 100644 --- a/buildtrigger/gitlabhandler.py +++ b/buildtrigger/gitlabhandler.py @@ -281,11 +281,12 @@ class GitLabBuildTrigger(BuildTriggerHandler): namespaces[namespace_id]['score'] = namespaces[namespace_id]['score'] + 1 else: owner = repo['namespace']['name'] + avatar_url = repo.get('owner', {}).get('avatar_url') namespaces[namespace_id] = { 'personal': owner == current_user['username'], 'id': namespace['path'], 'title': namespace['name'], - 'avatar_url': repo['owner']['avatar_url'], + 'avatar_url': avatar_url, 'score': 1, 'url': gl_client.host + '/' + namespace['path'], } diff --git a/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.html b/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.html index 1ecc8e28d..e81963bab 100644 --- a/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.html +++ b/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.html @@ -47,7 +47,7 @@ ng-value="namespace"> - + {{ namespace.id }} @@ -89,7 +89,7 @@

Select Repository

Select a repository in - + {{ $ctrl.local.selectedNamespace.id }} @@ -187,7 +187,7 @@

Configure Trigger

Configure trigger options for - + {{ $ctrl.local.selectedNamespace.id }}/{{ $ctrl.local.selectedRepository.name }} @@ -317,7 +317,7 @@ ng-if="$ctrl.local.triggerAnalysis.status == 'error'">

Verification Error

- There was an error when verifying the state of + There was an error when verifying the state of {{ $ctrl.local.selectedNamespace.id }}/{{ $ctrl.local.selectedRepository.name }}