Fix snippet commit bug because of different Gitaly error

parent b8d307ac
......@@ -115,8 +115,10 @@ class SnippetRepository < ApplicationRecord
end
def invalid_path_error?(err)
err.is_a?(Gitlab::Git::Index::IndexError) &&
err.message.downcase.start_with?('invalid path', 'path cannot include directory traversal')
(err.is_a?(Gitlab::Git::Index::IndexError) &&
err.message.downcase.start_with?('invalid path', 'path cannot include directory traversal')) ||
(err.is_a?(Gitlab::Git::CommandError) &&
err.message.include?('CreateFile: invalid path'))
end
def invalid_signature_error?(err)
......
---
title: Fix snippet commit bug because of different Gitaly error
merge_request: 54662
author:
type: fixed
......@@ -286,6 +286,7 @@ RSpec.describe SnippetRepository do
context 'with git errors' do
it_behaves_like 'snippet repository with git errors', 'invalid://path/here', described_class::InvalidPathError
it_behaves_like 'snippet repository with git errors', '.git/hooks/pre-commit', described_class::InvalidPathError
it_behaves_like 'snippet repository with git errors', '../../path/traversal/here', described_class::InvalidPathError
it_behaves_like 'snippet repository with git errors', 'README', described_class::CommitError
......
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