Strip whitespace from Sentry URL
Adding extra whitespace in the DSN could prevent the server from starting due to InvalidURIErrors in sentry-raven. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/49621
This commit is contained in:
parent
fb81210ba7
commit
775081ba56
|
@ -219,6 +219,7 @@ class ApplicationSetting < ActiveRecord::Base
|
||||||
validate :terms_exist, if: :enforce_terms?
|
validate :terms_exist, if: :enforce_terms?
|
||||||
|
|
||||||
before_validation :ensure_uuid!
|
before_validation :ensure_uuid!
|
||||||
|
before_validation :strip_sentry_values
|
||||||
|
|
||||||
before_save :ensure_runners_registration_token
|
before_save :ensure_runners_registration_token
|
||||||
before_save :ensure_health_check_access_token
|
before_save :ensure_health_check_access_token
|
||||||
|
@ -382,6 +383,11 @@ class ApplicationSetting < ActiveRecord::Base
|
||||||
super(levels.map { |level| Gitlab::VisibilityLevel.level_value(level) })
|
super(levels.map { |level| Gitlab::VisibilityLevel.level_value(level) })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def strip_sentry_values
|
||||||
|
sentry_dsn.strip! if sentry_dsn.present?
|
||||||
|
clientside_sentry_dsn.strip! if clientside_sentry_dsn.present?
|
||||||
|
end
|
||||||
|
|
||||||
def performance_bar_allowed_group
|
def performance_bar_allowed_group
|
||||||
Group.find_by_id(performance_bar_allowed_group_id)
|
Group.find_by_id(performance_bar_allowed_group_id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Strip whitespace from Sentry URL
|
||||||
|
merge_request: 21703
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -305,6 +305,36 @@ describe ApplicationSetting do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'setting Sentry DSNs' do
|
||||||
|
context 'server DSN' do
|
||||||
|
it 'strips leading and trailing whitespace' do
|
||||||
|
subject.update(sentry_dsn: ' http://test ')
|
||||||
|
|
||||||
|
expect(subject.sentry_dsn).to eq('http://test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'handles nil values' do
|
||||||
|
subject.update(sentry_dsn: nil)
|
||||||
|
|
||||||
|
expect(subject.sentry_dsn).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'client-side DSN' do
|
||||||
|
it 'strips leading and trailing whitespace' do
|
||||||
|
subject.update(clientside_sentry_dsn: ' http://test ')
|
||||||
|
|
||||||
|
expect(subject.clientside_sentry_dsn).to eq('http://test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'handles nil values' do
|
||||||
|
subject.update(clientside_sentry_dsn: nil)
|
||||||
|
|
||||||
|
expect(subject.clientside_sentry_dsn).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#disabled_oauth_sign_in_sources=' do
|
describe '#disabled_oauth_sign_in_sources=' do
|
||||||
before do
|
before do
|
||||||
allow(Devise).to receive(:omniauth_providers).and_return([:github])
|
allow(Devise).to receive(:omniauth_providers).and_return([:github])
|
||||||
|
|
Loading…
Reference in New Issue