fix: cast boolean env() values to prevent type errors - #5046
Open
tuxpiper wants to merge 1 commit into
Open
Conversation
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(). Also fixes config/session.php's 'secure' cookie flag, which flows into Symfony's Cookie constructor (also strictly bool|null typed). Its default of null carries auto-detect semantics in Laravel, so it is cast to bool only when the env var is actually set, rather than coerced unconditionally like the others. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
tuxpiper
force-pushed
the
fix/bool-cast-env-config
branch
from
August 10, 2026 12:27
5fe10f9 to
81c76af
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Changes
config/app.php:debug(the value that directly triggers the crash above)config/database.php:strict,redis.clusterconfig/routes.php:private_onlyconfig/sentry.php:queue_job_transactions,send_default_piiconfig/session.php:secure— also flows into a strictly-typed Symfony constructor (Cookie). Its default isnull, which Laravel treats as "auto-detect from request scheme," so it's only cast toboolwhen the env var is actually set, to avoid silently forcing it tofalse.Test checklist
No behavior change for unset env vars — every default value round-trips through its own cast unchanged (
falsestaysfalse,truestaystrue,nullstaysnull).Existing test suite passes.
I certify that I ran my checklist
Fixes ushahidi/platform# .
Ping @ushahidi/platform