You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an endpoint like this one: POST /feeders/{id}/feed that triggers an action on a resource called feeder.
This endpoint have a security setting, and a custom uriTemplate on the resource.
new Post(
uriTemplate: '/feeders/{id}/feed',
...
security: 'is_granted(\'MANAGE\', object)',
),
When sending an ID that does not exist, I expect a 404 error, and one of my tests assert that.
But since version 3.1.11, I get a 401 error instead.
I can narrow down the apparition of the issue with #5583, that exclude POST method from Not Found early response in ApiPlatform/Symfony/EventListener/ReadListener.php
How to reproduce
Create a custom POST, with an uriTemplate, and a security condition.
Pass an unknown ID
Get a 401 instead of a 404
Possible Solution
Simply removing the line 106 of ApiPlatform/Symfony/EventListener/ReadListener.php fixes the problem; but it might have other implications…
indeed this is a hard problem as since API Platform 2 POST is not supposed to have identifiers. Maybe that we can try to provide a flag to allow an operation to throw a not found exception when the data is null. I've added a pr with a proposal to change this behavior.
soyuka
added a commit
to soyuka/core
that referenced
this issue
Dec 7, 2023
API Platform version(s) affected: 3.1.11+
Description
I have an endpoint like this one:
POST /feeders/{id}/feed
that triggers an action on a resource called feeder.This endpoint have a
security
setting, and a customuriTemplate
on the resource.When sending an ID that does not exist, I expect a 404 error, and one of my tests assert that.
But since version 3.1.11, I get a 401 error instead.
I can narrow down the apparition of the issue with #5583, that exclude POST method from Not Found early response in ApiPlatform/Symfony/EventListener/ReadListener.php
How to reproduce
Possible Solution
Simply removing the line 106 of ApiPlatform/Symfony/EventListener/ReadListener.php fixes the problem; but it might have other implications…
Additional Context
I can reproduce this here, see the failing CI: Dean151/Aln-Symfony#71
My Post declaration is here: https://github.com/Dean151/Aln-Symfony/blob/470033da34e5f93bacb23b03d1bad7434f994588/src/Entity/AlnFeeder.php#L112
The text was updated successfully, but these errors were encountered: