jikan-me / jikan-rest

The REST API for Jikan
https://docs.api.jikan.moe/
MIT License
413 stars 268 forks source link

🐛 Empty query string parameters cause an internal server error #472

Closed nadla20xx closed 5 months ago

nadla20xx commented 5 months ago

Is there an existing issue for this?

Current Behavior

The API has returned an error: TypeError Status code: 0 Message: Cannot assign string to property App\Dto\SearchCommand::$page of type Spatie\LaravelData\Optional|int Trace: /var/www/jikan-rest/vendor/spatie/laravel-data/src/Resolvers/DataFromArrayResolver.php on line 49

Expected Behavior

The API should have returned a successful response with data.

Steps To Reproduce

Http Request: `GET /v4/anime?sfw=&unapproved=&page=&q=&sfw=&genres=&genres_exclude=&letter=&producers=&start_date=2001-01-01&end_date=2010-01-01

Environment

No response

Anything else?

No response

pushrbx commented 5 months ago

I've triaged this. Probably we need to upgrade LaravelData package. There is a PR in LaravelData's repo which might be the solution: https://github.com/spatie/laravel-data/pull/602

Otherwise some global transformer would be required, because all the endpoints are affected by this. I mean if you set an empty param, you get an error message instead of treating it empty/non-existent.

@nadla20xx For now I can only recommend not passing empty params to the API.

pushrbx commented 5 months ago

Found the source of the issue, it wasn't the laravel data package version. :tada: