Skip to content

Empty include path causes error #69

Closed
@lindyhopchris

Description

@lindyhopchris

Sending a request e.g. `GET /api/v1/posts?include=" causes an error when casting the query parameters to our Query Parameters object.

In this scenario, the empty include path should be interpretted as the client explicitly saying it does not want any include paths. I.e. an empty include paths object.

[2021-04-12 11:22:29] local.ERROR: Expecting a non-empty string. {"userId":5,"exception":"[object] (UnexpectedValueException(code: 0): Expecting a non-empty string. at /home/vagrant/dancecloud.com/vendor/laravel-json-api/core/src/Core/Query/RelationshipPath.php:67)
[stacktrace]
#0 /home/vagrant/dancecloud.com/vendor/laravel-json-api/core/src/Core/Query/IncludePaths.php(94): LaravelJsonApi\\Core\\Query\\RelationshipPath::fromString()
#1 [internal function]: LaravelJsonApi\\Core\\Query\\IncludePaths::LaravelJsonApi\\Core\\Query\\{closure}()
#2 /home/vagrant/dancecloud.com/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(640): array_map()
#3 /home/vagrant/dancecloud.com/vendor/laravel-json-api/core/src/Core/Query/IncludePaths.php(95): Illuminate\\Support\\Collection->map()
#4 /home/vagrant/dancecloud.com/vendor/laravel-json-api/laravel/src/Http/Requests/ResourceQuery.php(149): LaravelJsonApi\\Core\\Query\\IncludePaths::fromString()
#5 /home/vagrant/dancecloud.com/vendor/laravel-json-api/core/src/Core/Query/QueryParameters.php(89): LaravelJsonApi\\Laravel\\Http\\Requests\\ResourceQuery->includePaths()
#6 /home/vagrant/dancecloud.com/vendor/laravel-json-api/eloquent/src/HasQueryParameters.php(46): LaravelJsonApi\\Core\\Query\\QueryParameters::cast()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions