Skip to content

Bug in PostReceive#perform

Created by: erroric

Bug exists when Merge Request pushed with next deletion of merged branch.

In resque Failed Jobs list:

Worker
host:15362 on POST_RECEIVE at about 2 hours ago Retried about 2 hours ago
Class
PostReceive
Arguments
"project_name"
"31a9999a3d58629514babd86fe9074b961c0c0d3 "
"0000000000000000000000000000000000000000"
"refs/heads/some_branch"
"gitlab"
Exception
NoMethodError
Error
undefined method 'author' for nil:NilClass
/home/gitlab/gitlabhq/app/workers/post_receive.rb:10:in 'perform'

in post-receive hook log we can see:

project_name, babdf90b2dc02e901f99b84e1fcc2fa435063a18 , daca90f001355d6aa6cea4f4cfe91cba11a736f4 , refs/heads/some_branch, gitlab

project_name, 31a9999a3d58629514babd86fe9074b961c0c0d3 , 0000000000000000000000000000000000000000 , refs/heads/some_branch, gitlab

bug occurs in second push, when branch "some_branch" is deleted

/home/gitlab/gitlabhq/app/workers/post_receive.rb:10

 user = if identifier.eql? Gitlab.config.gitolite_admin_key
      email = project.commit(newrev).author.email

because newrev is "0000000000000000000000000000000000000000", it is not exists in project commits, so project.commit(newrev) returns nil

I think, simple way to fix it - add rescue for this statement