Skip to content

fix: cast boolean env() values to prevent type errors#5046

Open
tuxpiper wants to merge 1 commit intodevelopfrom
fix/bool-cast-env-config
Open

fix: cast boolean env() values to prevent type errors#5046
tuxpiper wants to merge 1 commit intodevelopfrom
fix/bool-cast-env-config

Conversation

@tuxpiper
Copy link
Copy Markdown
Member

@tuxpiper tuxpiper commented Mar 3, 2026

Symfony's HtmlErrorRenderer strictly validates that its debug argument is bool|callable, but env() can return strings. Add explicit (bool) casts to all boolean config values sourced from env().

This is one of the most often seen logs in production:

[2026-03-03 04:26:31] production.ERROR: Argument 1 passed to "Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer::__construct()" must be a boolean or a callable, "string" given. {"exception":"[object] (TypeError(code: 0): Argument 1 passed to \"Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer::__construct()\" must be a boolean or a callable, \"string\" given. at /var/www/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:53)
[stacktrace]
#0 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(566): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->__construct()
#1 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(520): Illuminate\\Foundation\\Exceptions\\Handler->renderExceptionWithSymfony()
#2 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(503): Illuminate\\Foundation\\Exceptions\\Handler->renderExceptionContent()
#3 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(482): Illuminate\\Foundation\\Exceptions\\Handler->convertExceptionToResponse()
#4 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(356): Illuminate\\Foundation\\Exceptions\\Handler->prepareResponse()
#5 /var/www/app/Exceptions/Handler.php(171): Illuminate\\Foundation\\Exceptions\\Handler->render()
#6 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(51): App\\Exceptions\\Handler->render()
#7 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(172): Illuminate\\Routing\\Pipeline->handleException()
#8 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#9 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then()
#10 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#11 /var/www/httpdocs/index.php(77): Illuminate\\Foundation\\Http\\Kernel->handle()
#12 {main}

This pull request makes the following changes:

Test checklist:

  • [ ]

  • I certify that I ran my checklist

Fixes ushahidi/platform# .

Ping @ushahidi/platform

Symfony's HtmlErrorRenderer strictly validates that its debug argument
is bool|callable, but env() can return strings. Add explicit (bool)
casts to all boolean config values sourced from env().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant