Commit 90ddfda6 authored by Stan Hu's avatar Stan Hu

Merge branch 'fj-60827-fix-web-strategy-error' into 'master'

Fix bug when project export to remote url fails

Closes #60827

See merge request gitlab-org/gitlab-ce!27614
parents 7734b834 7d85448b
---
title: Fix bug when project export to remote url fails
merge_request: 27614
author:
type: fixed
...@@ -30,10 +30,7 @@ module Gitlab ...@@ -30,10 +30,7 @@ module Gitlab
def handle_response_error(response) def handle_response_error(response)
unless response.success? unless response.success?
error_code = response.dig('Error', 'Code') || response.code raise StrategyError.new("Error uploading the project. Code #{response.code}: #{response.message}")
error_message = response.dig('Error', 'Message') || response.message
raise StrategyError.new("Error uploading the project. Code #{error_code}: #{error_message}")
end end
end end
......
...@@ -32,5 +32,17 @@ describe Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy do ...@@ -32,5 +32,17 @@ describe Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy do
strategy.execute(user, project) strategy.execute(user, project)
end end
context 'when upload fails' do
it 'stores the export error' do
stub_request(:post, example_url).to_return(status: [404, 'Page not found'])
strategy.execute(user, project)
errors = project.import_export_shared.errors
expect(errors).not_to be_empty
expect(errors.first).to eq "Error uploading the project. Code 404: Page not found"
end
end
end end
end end
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