Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty include path causes error #69

Closed
lindyhopchris opened this issue Apr 12, 2021 · 1 comment
Closed

Empty include path causes error #69

lindyhopchris opened this issue Apr 12, 2021 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@lindyhopchris
Copy link
Contributor

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()
@lindyhopchris lindyhopchris added the bug Something isn't working label Apr 12, 2021
@lindyhopchris lindyhopchris added this to the v1.0.0-beta.2 milestone Apr 12, 2021
@lindyhopchris
Copy link
Contributor Author

This bug also affected the sort and withCount query parameters, i.e. any string parameter. It's been fixed in the core package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant