Skip to content

nil branch name in Gitlab::Checks::ChangeAccess#branch_name_allowed_by_push_rule?

This looks like a significant regression in 9.5.4: https://gitlab.com/gitlab-org/gitlab-ee/commit/4ed9adf8e8a310ef3ac8836df59edd47b722243f

Due to a bug in our exception handling, this first appeared as https://gitlab.com/gitlab-org/gitlab-ce/issues/37680.

https://sentry.gitlap.com/gitlab/gitlabcom/issues/45418/

NoMethodError: undefined method `empty?' for nil:NilClass
  lib/gitlab/checks/change_access.rb:188:in `branch_name_allowed_by_push_rule?'
    return true if @branch_name.empty?
  lib/gitlab/metrics/instrumentation.rb:156:in `block in branch_name_allowed_by_push_rule?'
    trans.method_call_for(#{label.to_sym.inspect}).measure { super }
  lib/gitlab/metrics/method_call.rb:23:in `measure'
    retval = yield
  lib/gitlab/metrics/instrumentation.rb:156:in `branch_name_allowed_by_push_rule?'
    trans.method_call_for(#{label.to_sym.inspect}).measure { super }
  lib/gitlab/checks/change_access.rb:164:in `push_rule_check'
    unless branch_name_allowed_by_push_rule?(push_rule)
...
(137 additional frame(s) were not displayed)

NoMethodError: undefined method `empty?' for nil:NilClass
Edited by Stan Hu