summaryrefslogtreecommitdiff
path: root/lib/api/internal.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-12-24 09:03:58 -0800
committerStan Hu <stanhu@gmail.com>2017-12-24 09:39:08 -0800
commit36bdf3dc9ac290058b73ab54abeb9ba84b211b29 (patch)
tree06c13ffa218828c3a82495dbacf56a3f8e89de04 /lib/api/internal.rb
parent0c8d7e8460f74ba3a2345e42884ed96321fbb897 (diff)
downloadgitlab-ce-36bdf3dc9ac290058b73ab54abeb9ba84b211b29.tar.gz
Gracefully handle orphaned write deploy keys in /internal/post_receivesh-handle-orphaned-deploy-keys
On GitLab.com, there are write deploy keys with no associated users. Pushes with these deploy keys end with an Error 500 since we attempt to look up redirect message. If there is no user, don't attempt to display a redirect message. Closes #41466
Diffstat (limited to 'lib/api/internal.rb')
-rw-r--r--lib/api/internal.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index ccaaeca10d4..79b302aae70 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -190,9 +190,12 @@ module API
project = Gitlab::GlRepository.parse(params[:gl_repository]).first
user = identify(params[:identifier])
- redirect_message = Gitlab::Checks::ProjectMoved.fetch_redirect_message(user.id, project.id)
- if redirect_message
- output[:redirected_message] = redirect_message
+
+ # A user is not guaranteed to be returned; an orphaned write deploy
+ # key could be used
+ if user
+ redirect_message = Gitlab::Checks::ProjectMoved.fetch_redirect_message(user.id, project.id)
+ output[:redirected_message] = redirect_message if redirect_message
end
output