Fail on POST request
API Platform version(s) affected: 0.3.2
Description
Internal Server Error when trying to POST
Additional Context
I've tried to send update with the mercure ui and everything seems to work perfectly but i don't know why after the upgrade of mercure (0.3.2) everything seems to be broken.
"type": "https://tools.ietf.org/html/rfc2616#section-10",
"title": "An error occurred",
"detail": "Failed to send an update.",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/symfony/mercure/src/Hub.php",
"line": 104,
"args": []
},
{
"namespace": "Symfony\\Component\\Mercure",
"short_class": "Hub",
"class": "Symfony\\Component\\Mercure\\Hub",
"type": "->",
"function": "publish",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/api-platform/core/src/Bridge/Doctrine/EventListener/PublishMercureUpdatesListener.php",
"line": 243,
"args": []
},
{
"namespace": "ApiPlatform\\Core\\Bridge\\Doctrine\\EventListener",
"short_class": "PublishMercureUpdatesListener",
"class": "ApiPlatform\\Core\\Bridge\\Doctrine\\EventListener\\PublishMercureUpdatesListener",
"type": "->",
"function": "publishUpdate",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/api-platform/core/src/Bridge/Doctrine/EventListener/PublishMercureUpdatesListener.php",
"line": 129,
"args": []
},
{
"namespace": "ApiPlatform\\Core\\Bridge\\Doctrine\\EventListener",
"short_class": "PublishMercureUpdatesListener",
"class": "ApiPlatform\\Core\\Bridge\\Doctrine\\EventListener\\PublishMercureUpdatesListener",
"type": "->",
"function": "postFlush",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/symfony/doctrine-bridge/ContainerAwareEventManager.php",
"line": 64,
"args": []
},
{
"namespace": "Symfony\\Bridge\\Doctrine",
"short_class": "ContainerAwareEventManager",
"class": "Symfony\\Bridge\\Doctrine\\ContainerAwareEventManager",
"type": "->",
"function": "dispatchEvent",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php",
"line": 3457,
"args": []
},
{
"namespace": "Doctrine\\ORM",
"short_class": "UnitOfWork",
"class": "Doctrine\\ORM\\UnitOfWork",
"type": "->",
"function": "dispatchPostFlushEvent",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php",
"line": 475,
"args": []
},
{
"namespace": "Doctrine\\ORM",
"short_class": "UnitOfWork",
"class": "Doctrine\\ORM\\UnitOfWork",
"type": "->",
"function": "commit",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php",
"line": 378,
"args": []
},
{
"namespace": "Doctrine\\ORM",
"short_class": "EntityManager",
"class": "Doctrine\\ORM\\EntityManager",
"type": "->",
"function": "flush",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/var/cache/dev/ContainerIA2txq6/EntityManager_9a5be93.php",
"line": 129,
"args": []
},
{
"namespace": "ContainerIA2txq6",
"short_class": "EntityManager_9a5be93",
"class": "ContainerIA2txq6\\EntityManager_9a5be93",
"type": "->",
"function": "flush",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/src/DataPersister/UserDataPersister.php",
"line": 46,
"args": []
},
{
"namespace": "App\\DataPersister",
"short_class": "UserDataPersister",
"class": "App\\DataPersister\\UserDataPersister",
"type": "->",
"function": "persist",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/api-platform/core/src/DataPersister/ChainDataPersister.php",
"line": 59,
"args": []
},
{
"namespace": "ApiPlatform\\Core\\DataPersister",
"short_class": "ChainDataPersister",
"class": "ApiPlatform\\Core\\DataPersister\\ChainDataPersister",
"type": "->",
"function": "persist",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/api-platform/core/src/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersister.php",
"line": 58,
"args": []
},
{
"namespace": "ApiPlatform\\Core\\Bridge\\Symfony\\Bundle\\DataPersister",
"short_class": "TraceableChainDataPersister",
"class": "ApiPlatform\\Core\\Bridge\\Symfony\\Bundle\\DataPersister\\TraceableChainDataPersister",
"type": "->",
"function": "persist",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/api-platform/core/src/EventListener/WriteListener.php",
"line": 76,
"args": []
},
{
"namespace": "ApiPlatform\\Core\\EventListener",
"short_class": "WriteListener",
"class": "ApiPlatform\\Core\\EventListener\\WriteListener",
"type": "->",
"function": "onKernelView",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/symfony/event-dispatcher/Debug/WrappedListener.php",
"line": 117,
"args": []
},
{
"namespace": "Symfony\\Component\\EventDispatcher\\Debug",
"short_class": "WrappedListener",
"class": "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener",
"type": "->",
"function": "__invoke",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 230,
"args": []
},
{
"namespace": "Symfony\\Component\\EventDispatcher",
"short_class": "EventDispatcher",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->",
"function": "callListeners",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 59,
"args": []
},
{
"namespace": "Symfony\\Component\\EventDispatcher",
"short_class": "EventDispatcher",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->",
"function": "dispatch",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php",
"line": 151,
"args": []
},
{
"namespace": "Symfony\\Component\\EventDispatcher\\Debug",
"short_class": "TraceableEventDispatcher",
"class": "Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher",
"type": "->",
"function": "dispatch",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/symfony/http-kernel/HttpKernel.php",
"line": 162,
"args": []
},
{
"namespace": "Symfony\\Component\\HttpKernel",
"short_class": "HttpKernel",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "->",
"function": "handleRaw",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/symfony/http-kernel/HttpKernel.php",
"line": 79,
"args": []
},
{
"namespace": "Symfony\\Component\\HttpKernel",
"short_class": "HttpKernel",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "->",
"function": "handle",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/vendor/symfony/http-kernel/Kernel.php",
"line": 195,
"args": []
},
{
"namespace": "Symfony\\Component\\HttpKernel",
"short_class": "Kernel",
"class": "Symfony\\Component\\HttpKernel\\Kernel",
"type": "->",
"function": "handle",
"file": "/home/spocsk/Documents/Programmation/Symfony/backup/_citizens/public/index.php",
"line": 20,
"args": []
}
]
}```
Can you check in the logs if you have more details? From which version did you upgrade? Maybe do you need to adapt the config too if it's from an old version?
In the Symfony's logs there are noting written. I don't know how to see my previous version of mercure. And what do you mean by "adapt the config" ? And can you tell me if there is a better way to send updates with Api Platforme with mercure. Beacause i'm currently using this method.
@ApiResource(mercure=true,
my .env
###> symfony/mercure-bundle ###
# See https://symfony.com/doc/current/mercure.html#configuration
# The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
MERCURE_URL=http://127.0.0.1:3000/.well-known/mercure
# The public URL of the Mercure hub, used by the browser to connect
MERCURE_PUBLIC_URL=http://127.0.0.1:3000/.well-known/mercure
# The secret used to sign the JWTs
MERCURE_JWT_SECRET="test"
###< symfony/mercure-bundle ###
my mercure.yaml
mercure:
hubs:
default:
url: '%env(MERCURE_URL)%'
public_url: '%env(MERCURE_PUBLIC_URL)%'
jwt:
secret: '%env(MERCURE_JWT_SECRET)%'
publish: '*'
Discord: Spocsk#5434
I have the same issue with fresh installation!
Same issue too with same config 😭. (symfony 6.2, api-platform 3.0 and symfony/mercure-bundle 0.3.5)
excuse me did someone found a solution ?
Same issue here symfony 6.2.10, api-platform 3.0 and symfony/mercure-bundle 0.3.7