Skip to content
Snippets Groups Projects
Commit aa9616db authored by Georges Racinet's avatar Georges Racinet
Browse files

GitLab 16.2: matching error details for missing repo and unknown storage

In the case of unknown storage, we find it useful to repeat the requested
name, hence we simply stop comparing exactly the details.

In the case of the missing repository field, the new upstream message
is clearly better, so we adopt it.
parent 0625250d
No related branches found
No related tags found
2 merge requests!204Making Heptapod 0.40 the new oldstable,!199Minor adaptations for GitLab 16.2
Pipeline #73058 failed
......@@ -179,7 +179,7 @@
if exc.args[0] == 'storage':
context.abort(
StatusCode.INVALID_ARGUMENT,
f'GetStorageByName: no such storage: "{exc.args[1]}"'
f'storage not found: "{exc.args[1]}"'
)
exists = False
except ValueError as exc:
......@@ -595,7 +595,7 @@
first_req = next(request)
repo_msg = first_req.repository
if not (repo_msg.storage_name or repo_msg.relative_path):
context.abort(StatusCode.INVALID_ARGUMENT, 'empty Repository')
context.abort(StatusCode.INVALID_ARGUMENT, 'repository not set')
repo = self.load_repo(first_req.repository, context)
patterns = itertools.chain(
......@@ -689,8 +689,7 @@
if root_dir is None:
context.abort(
StatusCode.INVALID_ARGUMENT,
'remove all: GetStorageByName: '
'no such storage: "%s"' % storage
'remove all: storage not found: "%s"' % storage
)
root_dir = Path(os.fsdecode(root_dir)).resolve()
......
......@@ -1116,7 +1116,7 @@
tmpdir / 'temp_bname', [b'refs/heads/branch/default'],
without_repository=True)
assert exc_info_hg.value.code() == grpc.StatusCode.INVALID_ARGUMENT
assert exc_info_hg.value.details() == 'empty Repository'
assert exc_info_hg.value.details() == 'repository not set'
# test incrementality with negative revspecs
......
......@@ -215,7 +215,7 @@
if not storage_name:
# this is the best detection of a missing `repository` field
# in request, without having the request object itself
raise ValueError('empty repository')
raise ValueError('repository not set')
root_dir = self.storages.get(storage_name)
if root_dir is None:
......
......@@ -57,9 +57,7 @@
/// and more like this with time (e.g., as internal Git error get catched and handled).
pub fn default_repo_spec_error_status(err: RepoSpecError) -> Status {
match err {
RepoSpecError::MissingSpecification => {
Status::invalid_argument("missing repository specification")
}
RepoSpecError::MissingSpecification => Status::invalid_argument("repository not set"),
RepoSpecError::UnknownStorage(storage) => Status::invalid_argument(format!(
"GetStorageByName: no such storage: \"{}\"",
storage
......
......@@ -152,8 +152,6 @@
with pytest.raises(grpc.RpcError) as exc_info_git:
do_rpc('git', rel_path, storage='cargoship')
assert exc_info_hg.value.code() == exc_info_git.value.code()
assert 'no such storage' in exc_info_hg.value.details()
assert 'no such storage' in exc_info_git.value.details()
# test with a broken symlink (which points to itself)
# it used to be an error for both, with Gitaly complaining
......@@ -702,4 +700,4 @@
assert_compare_errors = rpc_helper.assert_compare_errors
# unknown storage
assert_compare_errors(storage_name='unknown')
assert_compare_errors(storage_name='unknown', same_details=False)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment