summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-05-10 14:45:09 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-05-10 14:45:09 +0000
commit9dc41a0993a38f99eeda9c2e8bb3ace070003496 (patch)
tree85d223ad978f16c19b107fa4acc4574aa6156e88 /app/services
parente09b609f0e41879a80e32c1e682f433d5318b89c (diff)
parente67481e079023e1319e91fabfb90b88c9a2b2655 (diff)
downloadgitlab-ce-9dc41a0993a38f99eeda9c2e8bb3ace070003496.tar.gz
Merge branch 'sh-fix-lfs-download-errors' into 'master'
Properly handle LFS Batch API response in project import Closes #61624 See merge request gitlab-org/gitlab-ce!28223
Diffstat (limited to 'app/services')
-rw-r--r--app/services/projects/lfs_pointers/lfs_download_link_list_service.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb b/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb
index 05974948505..9b72480d18b 100644
--- a/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb
+++ b/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb
@@ -37,7 +37,17 @@ module Projects
raise DownloadLinksError, response.message unless response.success?
- parse_response_links(response['objects'])
+ # Since the LFS Batch API may return a Content-Ttpe of
+ # application/vnd.git-lfs+json
+ # (https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md#requests),
+ # HTTParty does not know this is actually JSON.
+ data = JSON.parse(response.body)
+
+ raise DownloadLinksError, "LFS Batch API did return any objects" unless data.is_a?(Hash) && data.key?('objects')
+
+ parse_response_links(data['objects'])
+ rescue JSON::ParserError
+ raise DownloadLinksError, "LFS Batch API response is not JSON"
end
def parse_response_links(objects_response)