Commit 459e83fd authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Restrict pagination per_page possible values

Sentry error:
https://sentry.gitlab.net/gitlab/gitlabcom/issues/3168349

**Problem**

Providing `0` value for `per_page` causes various internal errors.

**Solution**

* Do not allow to provide 0 for per_page
* Return API error when this happens

Changelog: fixed
parent 63a7d839
......@@ -18,7 +18,7 @@ module API
helpers do
params :pagination do
optional :page, type: Integer, default: 1, desc: 'Current page number'
optional :per_page, type: Integer, default: 20, desc: 'Number of items per page'
optional :per_page, type: Integer, default: 20, desc: 'Number of items per page', except_values: [0]
end
end
end
......
......@@ -227,6 +227,12 @@ RSpec.describe API::Commits do
expect(response.headers['X-Page']).to eq('3')
end
end
context 'when per_page is 0' do
let(:per_page) { 0 }
it_behaves_like '400 response'
end
end
context 'with order parameter' do
......
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