diff options
author | Stan Hu <stanhu@gmail.com> | 2019-04-24 15:34:07 +0000 |
---|---|---|
committer | GitLab Release Tools Bot <robert+release-tools@gitlab.com> | 2019-04-29 18:26:05 +0000 |
commit | 9755b5abc4addddb63131cd95f5c469bfe442e03 (patch) | |
tree | 1fc49caa9d7986c9cda63c67ee9bd11e621e1229 | |
parent | a1e417e5285ac8826eff4cf1ee9a6d3fa7cad3d3 (diff) | |
download | gitlab-ce-9755b5abc4addddb63131cd95f5c469bfe442e03.tar.gz |
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
(cherry picked from commit 90ddfda612eba5533dccebbba205bac9dd8f0ac6)
aa0345a4 Fix error info retrieval on web project export
3 files changed, 18 insertions, 4 deletions
diff --git a/changelogs/unreleased/fj-60827-fix-web-strategy-error.yml b/changelogs/unreleased/fj-60827-fix-web-strategy-error.yml new file mode 100644 index 00000000000..ad707ca0225 --- /dev/null +++ b/changelogs/unreleased/fj-60827-fix-web-strategy-error.yml @@ -0,0 +1,5 @@ +--- +title: Fix bug when project export to remote url fails +merge_request: 27614 +author: +type: fixed diff --git a/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb b/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb index b30900f7c61..7a057d79921 100644 --- a/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb +++ b/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb @@ -30,10 +30,7 @@ module Gitlab def handle_response_error(response) unless response.success? - error_code = response.dig('Error', 'Code') || response.code - error_message = response.dig('Error', 'Message') || response.message - - raise StrategyError.new("Error uploading the project. Code #{error_code}: #{error_message}") + raise StrategyError.new("Error uploading the project. Code #{response.code}: #{response.message}") end end diff --git a/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb b/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb index ec17ad8541f..7c4ac62790e 100644 --- a/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb +++ b/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb @@ -32,5 +32,17 @@ describe Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy do strategy.execute(user, project) 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 |