Open
Description
Currently, the following AbstractObjectParser
methods:
declareInt
declareIntOrNull
declareLong
declareLongOrNull
declareIntArray
declareLongArray
truncate any floats / doubles passed to them, rather than throwing an IllegalArgumentException
. This means that fields defined as integer / long, can actually accept floats and doubles.
There are two issues with this:
- The customer may be dependent on this invalid behaviour (this is an integer defined field, and so should only accept integers) and behaviour from our side cannot be guaranteed. Therefore, imposing stricter validation ensures consistent behaviour moving forward/
- The following methods are used to parse API request bodies. When APIs accept parameters via query parameters, tighter validation is present, and floats are not accepted. This leads to a discrepancy between APIs accepting parameters via the request body and rejecting them as query parameters.
The scope of this change is to modify the above methods - any other others missing from the list - to throw an IllegalArgumentException
when non-integer / non-long values are passed. This will ensure consistency between parameters passed in the body of the request, and those in the query parameters