Skip to content

Fix dingtalk project find by alias

毛超请求将fix-dingtalk-project-ailas-issue合并到main-jh

if user send wrong project alias in message in ultra licensed gitlab, it will throw error and dingtalk will have no response.

dingtalk message 123123gitlab-cn/gitlab issue show 1

gitlab.log

NoMethodError (undefined method `issues_enabled?' for true:TrueClass):
  /Users/chaomao/workspace/gitlab/gdk/gitlab/jh/lib/gitlab/chatops_commands/issue_command.rb:7:in `available?'
  /Users/chaomao/workspace/gitlab/gdk/gitlab/jh/lib/gitlab/chatops_commands/command.rb:47:in `block in available_commands'
  /Users/chaomao/workspace/gitlab/gdk/gitlab/jh/lib/gitlab/chatops_commands/command.rb:46:in `keep_if'
  /Users/chaomao/workspace/gitlab/gdk/gitlab/jh/lib/gitlab/chatops_commands/command.rb:46:in `available_commands'
  /Users/chaomao/workspace/gitlab/gdk/gitlab/jh/lib/gitlab/chatops_commands/command.rb:36:in `match_command'
  /Users/chaomao/workspace/gitlab/gdk/gitlab/jh/lib/gitlab/chatops_commands/command.rb:20:in `execute'
  /Users/chaomao/workspace/gitlab/gdk/gitlab/jh/lib/gitlab/dingtalk/message_handler.rb:81:in `handle_message'
  /Users/chaomao/workspace/gitlab/gdk/gitlab/jh/lib/gitlab/dingtalk/message_handler.rb:29:in `execute'
  /Users/chaomao/workspace/gitlab/gdk/gitlab/jh/lib/gitlab/chatops/third_party_robot_handler.rb:45:in `execute'
  /Users/chaomao/workspace/gitlab/gdk/gitlab/jh/lib/jh/api/integrations.rb:17:in `block (4 levels) in <module:Integrations>'

the root cause is if ::License.feature_available?(:project_aliases) is return true, this method still return true even ProjectAlias return nil.

(::License.feature_available?(:project_aliases) ||
 ProjectAlias.find_by_name(path)&.project)

合并请求报告

加载中