Skip to content

fix: return HTTP 503 on bootstrap error for /health endpoint#1961

Open
kayjoosten wants to merge 1 commit intomainfrom
fix/1936-health-endpoint-503-on-error
Open

fix: return HTTP 503 on bootstrap error for /health endpoint#1961
kayjoosten wants to merge 1 commit intomainfrom
fix/1936-health-endpoint-503-on-error

Conversation

@kayjoosten
Copy link
Copy Markdown
Contributor

Summary

  • Wraps the env validation block in public/index.php in a try-catch(\Throwable) so misconfiguration errors (e.g. missing/short APP_SECRET) return HTTP 503 instead of a PHP fatal error page with HTTP 200
  • Response format matches the openconext/monitor-bundle DOWN convention: {"status":"DOWN","message":"..."}
  • Adds error_log() so bootstrap failures still appear in server logs
  • Adds functional test coverage for the public /health route

Test Plan

  • Set APP_ENV=prod and APP_SECRET=short in devconf .env, restart engine container, hit GET https://engine.dev.openconext.local/health — expect HTTP 503 with {"status":"DOWN","message":"APP_SECRET must be at least 32 characters long in production."}
  • Revert .env, restart, hit /health again — expect HTTP 200 {"status":"UP"}
  • Run ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --testsuite=functional --filter=MonitorControllerTest — expect 3 tests passing

Closes #1936

Uncaught exceptions thrown during bootstrap (before Symfony starts)
produced a PHP fatal error page with HTTP 200. Narrow the try-catch
to only the env validation block so monitoring systems receive a 503
JSON response consistent with the monitor-bundle DOWN format, without
interfering with response sending or kernel termination.

Closes #1936
@kayjoosten kayjoosten requested a review from johanib April 1, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/health endpoint return 200 status even if the call fails

1 participant