Description
When providing an empty value to any of the fields
query parameters, the server returns a 500 error with server error being:
LaravelJsonApi\Validation\Rules\AllowedFieldSets::notAllowed(): Argument # 2 ($fields) must be of type string, null given, called in /vendor/laravel-json-api/validation/src/Rules/AllowedFieldSets.php on line 232"
For example, if the client requests the following:
It certainly makes sense for an error to be returned, but I would have expected a validation error given that this is a client issue. It also ends up in our error tracking software which isn't great.
While not an ideal solution, I wondered if adding validation for each of the fields
parameters (current resource and all relations) would help. Unfortunately, it still returns the same 500 error for the above request. For example:
'fields' => [
'nullable',
'array',
JsonApiRule::fieldSets(),
],
'fields.employees' => 'filled',