Commit afa81d58 authored by Matthias Käppler's avatar Matthias Käppler

Merge branch '356798-fix-terraform-state-lock-error' into 'master'

Handle nil values in Grape length limit validator

See merge request gitlab-org/gitlab!84240
parents 3ddbc0d0 9d26c3f3
...@@ -7,7 +7,7 @@ module API ...@@ -7,7 +7,7 @@ module API
def validate_param!(attr_name, params) def validate_param!(attr_name, params)
value = params[attr_name] value = params[attr_name]
return if value.size <= @option return if value.nil? || value.size <= @option
raise Grape::Exceptions::Validation.new( raise Grape::Exceptions::Validation.new(
params: [@scope.full_name(attr_name)], params: [@scope.full_name(attr_name)],
......
...@@ -22,4 +22,10 @@ RSpec.describe API::Validations::Validators::Limit do ...@@ -22,4 +22,10 @@ RSpec.describe API::Validations::Validators::Limit do
expect_validation_error('test' => "#{'a' * 256}") expect_validation_error('test' => "#{'a' * 256}")
end end
end end
context 'value is nil' do
it 'does not raise a validation error' do
expect_no_validation_error('test' => nil)
end
end
end end
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