@tsteur opened this Issue on December 23rd 2021 Member

Getting below error.

Error: {"message":"Argument 2 passed to Piwik\Plugins\Feedback\API::sendFeedbackForFeature() must be of the type int, string given","file":"plugins\/Feedback\/API.php","line":38," "request_id":"d5fc2","backtrace":" on /plugins\/Feedback\/API.php(38)\n#0 [internal function]: Piwik\Plugins\Feedback\API->sendFeedbackForFeature('Help', 'index.php\/.', 'dislikeother', 'e')\

I noticed this API is enforcing specific types. I'm thinking in API's we should likely not make use of PHP types like (?string $featureName, int $like as it could cause issues like fatal errors when you actually want a regular error message response that the input is not correct.

Could we maybe remove those types there and in general document to not use any types there? We could maybe even have an automated test that checks that no API has specific parameters enforced.

It can be frustrating otherwise when consuming the API and all you get is an HTTP 500 and you don't know what you're doing wrong. Also we get emailed about it every time this happens which can be annoying too.

@justinvelluppillai commented on January 6th 2022 Member

@peterhashair it'd be good to check if you can add or update any documentation to reflect @tsteur's suggestion of not typing API endpoints so this is clear in future as part of this task.

@peterhashair commented on January 6th 2022 Contributor
@justinvelluppillai commented on January 6th 2022 Member

I mean adding a note to not use typed parameters, perhaps on this page https://developer.matomo.org/guides/apis

@peterhashair commented on January 6th 2022 Contributor

@justinvelluppillai right, ah how do I access that API site :)

@justinvelluppillai commented on January 6th 2022 Member

There's an Edit on Github link at the bottom of the page

This Issue was closed on January 10th 2022
Powered by GitHub Issue Mirror