Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b3754208
Commit
b3754208
authored
May 10, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
974c93b4
9dc41a09
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
2 deletions
+35
-2
app/services/projects/lfs_pointers/lfs_download_link_list_service.rb
...s/projects/lfs_pointers/lfs_download_link_list_service.rb
+11
-1
changelogs/unreleased/sh-fix-lfs-download-errors.yml
changelogs/unreleased/sh-fix-lfs-download-errors.yml
+5
-0
spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb
...jects/lfs_pointers/lfs_download_link_list_service_spec.rb
+19
-1
No files found.
app/services/projects/lfs_pointers/lfs_download_link_list_service.rb
View file @
b3754208
...
...
@@ -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
)
...
...
changelogs/unreleased/sh-fix-lfs-download-errors.yml
0 → 100644
View file @
b3754208
---
title
:
Properly handle LFS Batch API response in project import
merge_request
:
28223
author
:
type
:
fixed
spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb
View file @
b3754208
...
...
@@ -33,7 +33,10 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do
before
do
allow
(
project
).
to
receive
(
:lfs_enabled?
).
and_return
(
true
)
allow
(
Gitlab
::
HTTP
).
to
receive
(
:post
).
and_return
(
objects_response
)
response
=
instance_double
(
HTTParty
::
Response
)
allow
(
response
).
to
receive
(
:body
).
and_return
(
objects_response
.
to_json
)
allow
(
response
).
to
receive
(
:success?
).
and_return
(
true
)
allow
(
Gitlab
::
HTTP
).
to
receive
(
:post
).
and_return
(
response
)
end
describe
'#execute'
do
...
...
@@ -89,6 +92,21 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do
expect
{
subject
.
send
(
:get_download_links
,
new_oids
)
}.
to
raise_error
(
described_class
::
DownloadLinksError
)
end
shared_examples
'JSON parse errors'
do
|
body
|
it
'raises error'
do
response
=
instance_double
(
HTTParty
::
Response
)
allow
(
response
).
to
receive
(
:body
).
and_return
(
body
)
allow
(
response
).
to
receive
(
:success?
).
and_return
(
true
)
allow
(
Gitlab
::
HTTP
).
to
receive
(
:post
).
and_return
(
response
)
expect
{
subject
.
send
(
:get_download_links
,
new_oids
)
}.
to
raise_error
(
described_class
::
DownloadLinksError
)
end
end
it_behaves_like
'JSON parse errors'
,
'{'
it_behaves_like
'JSON parse errors'
,
'{}'
it_behaves_like
'JSON parse errors'
,
'{ foo: 123 }'
end
describe
'#parse_response_links'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment