liip / LiipMonitorBundle

Integrates the LiipMonitor library into Symfony
http://liip.ch
467 stars 103 forks source link

Health check REST api error - unsupported post #275

Closed succinct closed 2 years ago

succinct commented 2 years ago

I'm migrating a site from Symfony 3.4 to Symfony 6, and I'm not able to get my health checks to work from the REST api. They do work fine from the console. The POST to https://localhost/monitor/health/run?group=default throws the following error:

Symfony Exception
UnsupportedMediaTypeHttpException
HTTP 415 Unsupported Media Type
Request body format '' not supported

As I mentioned, the checks work as expected when running from the console:

/prj/gateway3/www$ symfony console monitor:health
WARNING Apache exposure: Apache is exposed [Server: nginx/1.18.0 (Ubuntu)]
FAIL Apache X-Frame Options: X-Frame-Options HTTP header not present
FAIL Apache XSS Protection: X-XSS-Protection HTTP header not present
OK Database: gwctl: Users found: 8
OK Database: mxctl: Contacts found: 8
OK Secure cookie: No cookies set
OK Dir Writable: All paths are writable directories.
OK Doctrine DBAL "default" connection
kbond commented 2 years ago

Hi @succinct, I just tested this on a new Symfony 6 app and couldn't get the same error.

What is the stack trace of the UnsupportedMediaTypeHttpException?

Do you happen to have a request listener that is converting json requests?

succinct commented 2 years ago

@kbond your comment prompted me to dig into the request listeners for json, and it turns out to have been caused by my use of FOSRestBundle, which I use for the website's API layer. I added a new firewall to handle the health checks, and now everything seems to be working fine!