Commit 4a5260d5 authored by Furkan Ayhan's avatar Furkan Ayhan

Merge branch 'aw-fix-invalid-ref-in-blob-resolver' into 'master'

Fix GRPC 500 from BlobsResolver

See merge request gitlab-org/gitlab!80747
parents c1c597bc 8eb9f47a
......@@ -30,8 +30,17 @@ module Resolvers
return [] if repository.empty?
ref ||= repository.root_ref
validate_ref(ref)
repository.blobs_at(paths.map { |path| [ref, path] })
end
private
def validate_ref(ref)
unless Gitlab::GitRefValidator.validate(ref)
raise Gitlab::Graphql::Errors::ArgumentError, 'Ref is not valid'
end
end
end
end
......@@ -68,6 +68,28 @@ RSpec.describe Resolvers::BlobsResolver do
)
end
end
context 'when specifying an invalid ref' do
let(:ref) { 'ma:in' }
it 'raises an ArgumentError' do
expect { resolve_blobs }.to raise_error(
Gitlab::Graphql::Errors::ArgumentError,
'Ref is not valid'
)
end
end
context 'when passing an empty ref' do
let(:ref) { '' }
it 'raises an ArgumentError' do
expect { resolve_blobs }.to raise_error(
Gitlab::Graphql::Errors::ArgumentError,
'Ref is not valid'
)
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