Create custom validator for revision params in the API

Problem to solve

In the past, we have had problems with revisions that starts with -. Gitaly has added this kind of validation in several RPC raising the error revision can't start with '-'.

At the moment, in the API we don't perform any validation on this kind of param.

Further details

If we stop the request when the revision is invalid, we can avoid some RPCs and unnecessary work from the platform.

Proposal

The idea is to create a Grape::Validations object (lib/api/helpers/custom_validators.rb) that checks if the revision starts with -. If it does, then we can raise the error: revision can't start with '-'. Please provide the full revision path.

Then we have to review the different endpoints (for example searching for :ref,) and add this validator.

What does success look like, and how can we measure that?

Endpoints that accept the revision of a repository as a param should raise an error when the revision is invalid.

Edited Oct 10, 2019 by Francisco Javier López
Assignee Loading
Time tracking Loading