Commit 9b8c2b2e authored by Kerri Miller's avatar Kerri Miller

Merge branch '222970-207742-fix-500-webhooks-urls-not-encoded' into 'master'

Fix 500 errors entering a webhook URL not encoded

See merge request gitlab-org/gitlab!51109
parents 60b0dd17 37b2cc2a
......@@ -54,7 +54,9 @@ class WebHookService
http_status: response.code,
message: response.to_s
}
rescue SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::OpenTimeout, Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError, Gitlab::HTTP::RedirectionTooDeep, Gitlab::Json::LimitedEncoder::LimitExceeded => e
rescue SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH,
Net::OpenTimeout, Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError, Gitlab::HTTP::RedirectionTooDeep,
Gitlab::Json::LimitedEncoder::LimitExceeded, URI::InvalidURIError => e
execution_duration = Gitlab::Metrics::System.monotonic_time - start_time
log_execution(
trigger: hook_name,
......
---
title: Fix 500 errors entering a webhook URL not encoded
merge_request: 51109
author:
type: fixed
......@@ -6,7 +6,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Webhooks
Project webhooks allow you to trigger a URL if for example new code is pushed or
Project webhooks allow you to trigger a percent-encoded URL if, for example, new code is pushed or
a new issue is created. You can configure webhooks to listen for specific events
like pushes, issues or merge requests. GitLab sends a POST request with data
to the webhook URL.
......
......@@ -131,6 +131,15 @@ RSpec.describe WebHookService do
end
end
context 'when url is not encoded' do
let(:project_hook) { create(:project_hook, url: 'http://server.com/my path/') }
it 'handles exceptions' do
expect(service_instance.execute).to eq(status: :error, message: 'bad URI(is not URI?): "http://server.com/my path/"')
expect { service_instance.execute }.not_to raise_error
end
end
context 'when request body size is too big' do
it 'does not perform the request' do
stub_const("#{described_class}::REQUEST_BODY_SIZE_LIMIT", 10.bytes)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment