Skip to content
代码片段 群组 项目
提交 398651ab 编辑于 作者: Vasilii Iakliushin's avatar Vasilii Iakliushin
浏览文件

Fix undefined method `downcase' error

Contributes to
https://new-sentry.gitlab.net/organizations/gitlab/issues/483109

**Problem**

Users can provide an object type that doesn't support `downcase`
method (for example, a hash). That leads to 500 error.

**Solution**

Convert the ref_type value to string before calling `downcase` method.

Changelog: fixed
上级 7aa25677
No related branches found
No related tags found
无相关合并请求
...@@ -15,7 +15,7 @@ class RefExtractor ...@@ -15,7 +15,7 @@ class RefExtractor
class << self class << self
def ref_type(type) def ref_type(type)
return unless REF_TYPES.include?(type&.downcase) return unless REF_TYPES.include?(type.to_s.downcase)
type.downcase type.downcase
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ExtractsRef do RSpec.describe ExtractsRef, feature_category: :source_code_management do
include described_class include described_class
include RepoHelpers include RepoHelpers
...@@ -98,6 +98,12 @@ ...@@ -98,6 +98,12 @@
it { is_expected.to eq(nil) } it { is_expected.to eq(nil) }
end end
context 'when ref_type is a hash' do
let(:ref_type) { { 'just' => 'hash' } }
it { is_expected.to eq(nil) }
end
end end
it_behaves_like 'extracts refs' it_behaves_like 'extracts refs'
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册