FriendsOfSymfony / FOSRestBundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony
http://symfony.com/doc/master/bundles/FOSRestBundle/index.html
MIT License
2.79k stars 703 forks source link

@Rest\POST vs @Rest\Post #2299

Closed meshenka closed 3 years ago

meshenka commented 3 years ago

We stumble upon a very very strange bug

when APP_ENV=prod if we run bin/console ca:cl && bin/console cache:warmup IF the first controller class he found use the Uppercase Annotation, then something goes wrong and we can see errors like

PHP   2. Symfony\Bundle\FrameworkBundle\Console\Application->run() /var/www/app/bin/console:40
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/app/vendor/symfony/console/Application.php:149
PHP   4. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/app/vendor/symfony/framework-bundle/Console/Application.php:83
PHP   5. Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() /var/www/app/vendor/symfony/console/Application.php:273
PHP   6. Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() /var/www/app/vendor/symfony/framework-bundle/Console/Application.php:97
PHP   7. Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand->run() /var/www/app/vendor/symfony/console/Application.php:1027
PHP   8. Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand->execute() /var/www/app/vendor/symfony/console/Command/Command.php:255
PHP   9. Symfony\Bundle\FrameworkBundle\Routing\Router->getRouteCollection() /var/www/app/vendor/symfony/framework-bundle/Command/RouterMatchCommand.php:89
PHP  10. Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader->load() /var/www/app/vendor/symfony/framework-bundle/Routing/Router.php:73
PHP  11. Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader->load() /var/www/app/vendor/symfony/framework-bundle/Routing/DelegatingLoader.php:85
PHP  12. Symfony\Component\Routing\Loader\ContainerLoader->load() /var/www/app/vendor/symfony/config/Loader/DelegatingLoader.php:40
PHP  13. App\Kernel->loadRoutes() /var/www/app/vendor/symfony/routing/Loader/ObjectLoader.php:67
PHP  14. App\Kernel->configureRoutes() /var/www/app/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:93
PHP  15. Symfony\Component\Routing\RouteCollectionBuilder->import() /var/www/app/src/Kernel.php:54
PHP  16. Symfony\Component\Routing\RouteCollectionBuilder->load() /var/www/app/vendor/symfony/routing/RouteCollectionBuilder.php:62
PHP  17. Symfony\Component\Routing\Loader\GlobFileLoader->load() /var/www/app/vendor/symfony/routing/RouteCollectionBuilder.php:372
PHP  18. Symfony\Component\Routing\Loader\GlobFileLoader->import() /var/www/app/vendor/symfony/routing/Loader/GlobFileLoader.php:32
PHP  19. Symfony\Component\Routing\Loader\GlobFileLoader->doImport() /var/www/app/vendor/symfony/config/Loader/FileLoader.php:104
PHP  20. Symfony\Component\Routing\Loader\YamlFileLoader->load() /var/www/app/vendor/symfony/config/Loader/FileLoader.php:165
PHP  21. Symfony\Component\Routing\Loader\YamlFileLoader->parseImport() /var/www/app/vendor/symfony/routing/Loader/YamlFileLoader.php:85
PHP  22. Symfony\Component\Routing\Loader\YamlFileLoader->import() /var/www/app/vendor/symfony/routing/Loader/YamlFileLoader.php:191
PHP  23. Symfony\Component\Routing\Loader\YamlFileLoader->doImport() /var/www/app/vendor/symfony/config/Loader/FileLoader.php:104
PHP  24. Symfony\Component\Routing\Loader\AnnotationDirectoryLoader->load() /var/www/app/vendor/symfony/config/Loader/FileLoader.php:165
PHP  25. Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader->load() /var/www/app/vendor/symfony/routing/Loader/AnnotationDirectoryLoader.php:67

Warning: Invalid argument supplied for foreach() in /var/www/app/vendor/symfony/routing/Loader/AnnotationClassLoader.php on line 115

when doing a bin/console router:match [a route, even one that does not exist]

if the fist controller this process find use @Rest{Post,Patch,Put,Delete,Get} then it is all good forcing APP_DEBUG=true or APP_ENV=dev does not have the issue

xabbuh commented 3 years ago

Can you create a small example application that allows to reproduce this? Otherwise, I am afraid that noone will be able to help you.

meshenka commented 3 years ago

as a work around i just fixed all annotation to use Lowercase, but i will try to have a simple POC

meshenka commented 3 years ago

here is my POC repo https://github.com/meshenka/rest-demo-issue-2299

with the exact version i had seen this bug, but i cannot reproduce, there must be another moving part that trigger this issue :(

xabbuh commented 3 years ago

Does that mean that the issue goes away if you update FOSRestBundle to, for example, 2.8.6?

meshenka commented 3 years ago

Does that mean that the issue goes away if you update FOSRestBundle to, for example, 2.8.6?

could not reproduce outside in a small POC, 2.8.2 or 2.8.6 or latest

xabbuh commented 3 years ago

Should we close then? Without being able to reproduce I am afraid that we cannot do anything here.