Skip to content

Rename GitAccess::UnauthorizedError and align git returned error codes

What does this MR do?

In git workflows, when the user cannot perform the action because of some access right, we trigger the error Gitlab::GitAccess::UnauthorizedError. Nevertheless, when the error is caught in https://gitlab.com/gitlab-org/gitlab/blob/master/app/controllers/repositories/git_http_controller.rb#L10, the response code we return is a 403 (Forbidden error). Moreover, the error code returned for the same error is different when the request is made through the internal API (https://gitlab.com/gitlab-org/gitlab/blob/master/lib/api/internal/base.rb#L53), which is 401.

The error naming can be misleading since, in other parts of the workflow like https://gitlab.com/gitlab-org/gitlab/blob/master/app/controllers/repositories/git_http_controller.rb#L10 and https://gitlab.com/gitlab-org/gitlab/blob/master/app/controllers/repositories/git_http_client_controller.rb#L91, we return real 401 (Unauthorized) errors.

It would be best if we rename Gitlab::GitAccess::UnauthorizedError to Gitlab::GitAccess::ForbiddenError, since that is really what they are.

It would be also good if we align the error codes to be both 403.

Does this MR meet the acceptance criteria?

Conformity

Merge request reports