diff options
author | Robert Speicher <robert@gitlab.com> | 2018-09-06 16:29:48 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-09-06 16:29:48 +0000 |
commit | 2d16f4794b43966595e8c6b6405b55c60e94e866 (patch) | |
tree | d07fad75444b3491ee8b215ff65643605b1e770b | |
parent | 607a2562380515ddb2909db9d0486b022342add9 (diff) | |
parent | d2161350cc8f8fc5fd9b486a07d518e76a76cde7 (diff) | |
download | gitlab-ce-2d16f4794b43966595e8c6b6405b55c60e94e866.tar.gz |
Merge branch 'ccr/6699_image_for_object_error' into 'master'
Handled exception during file upload
See merge request gitlab-org/gitlab-ce!21528
-rw-r--r-- | app/controllers/concerns/uploads_actions.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/ccr-6699_image_for_object_error.yml | 6 | ||||
-rw-r--r-- | spec/controllers/projects/uploads_controller_spec.rb | 14 |
3 files changed, 22 insertions, 0 deletions
diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb index 434459a225a..bb8c245a5b7 100644 --- a/app/controllers/concerns/uploads_actions.rb +++ b/app/controllers/concerns/uploads_actions.rb @@ -53,6 +53,8 @@ module UploadsActions maximum_size: Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i) render json: authorized + rescue SocketError + render json: "Error uploading file", status: :internal_server_error end private diff --git a/changelogs/unreleased/ccr-6699_image_for_object_error.yml b/changelogs/unreleased/ccr-6699_image_for_object_error.yml new file mode 100644 index 00000000000..dec1adaceff --- /dev/null +++ b/changelogs/unreleased/ccr-6699_image_for_object_error.yml @@ -0,0 +1,6 @@ +--- +title: Handles exception during file upload - replaces the stack trace with a small + error message. +merge_request: 21528 +author: +type: fixed diff --git a/spec/controllers/projects/uploads_controller_spec.rb b/spec/controllers/projects/uploads_controller_spec.rb index 325ee53aafb..9802e4d5b1e 100644 --- a/spec/controllers/projects/uploads_controller_spec.rb +++ b/spec/controllers/projects/uploads_controller_spec.rb @@ -18,6 +18,20 @@ describe Projects::UploadsController do end end + context "when exception occurs" do + before do + allow(FileUploader).to receive(:workhorse_authorize).and_raise(SocketError.new) + sign_in(create(:user)) + end + + it "responds with status internal_server_error" do + post_authorize + + expect(response).to have_gitlab_http_status(500) + expect(response.body).to eq('Error uploading file') + end + end + def post_authorize(verified: true) request.headers.merge!(workhorse_internal_api_request_header) if verified |