Repository navigation
fix(config): stop empty boolean env vars from switching flags on - #5838
Open
Lesereingrape wants to merge 7 commits into
Open
Lesereingrape wants to merge 7 commits into
Lesereingrape wants to merge 7 commits into
Conversation
Every boolean CONFIG property parses its env var with `os.getenv(name, default).lower()[:1] in 'ty1'`. Substring containment makes the empty string a match for any string, so `ANONYMIZED_TELEMETRY=` in an .env file - or a docker-compose entry written without a value - turns telemetry, cloud sync, version checks and the rest ON instead of off. Test against the first character of an explicit tuple of true-ish values instead. Unset values still fall back to each property's own default and every other spelling behaves as before.
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
sun04222
added a commit
to sun04222/browser-use
that referenced
this pull request
Oct 23, 2026
… config.py taken from PR head)
This branch has not been deployed
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.
What
Fixes #5837.
_env_bool()replaces the six copies ofos.getenv(NAME, default).lower()[:1] in 'ty1'onCONFIG. The only behaviour that changes is the one that was inverted: a boolean env var that is present but empty now readsFalseinstead ofTrue.x[:1] in 'ty1'is substring containment, and''is a substring of everything — soANONYMIZED_TELEMETRY=in a.env, or adocker-compose.ymllist entry written without a value, switched telemetry, cloud sync, version checks and the rest on.'0'and'no'were already parsed correctly;''was the only broken input, which is why the fix is the container type rather than the value list.Why this shape
defaultargument, soANONYMIZED_TELEMETRYandBROWSER_USE_VERSION_CHECKstill default toTruewhen unset andSKIP_LLM_API_KEY_VERIFICATIONstill defaults toFalse.BROWSER_USE_CLOUD_SYNCstill inheritsstr(self.ANONYMIZED_TELEMETRY)— andtest_cloud_sync_inherits_telemetrypasses.'true','True','TRUE','yes','y','1'still readTrue;'false','no','n','0',' ','maybe'still readFalse. Measured value-by-value before and after,''is the only row that differs:''means false, not unset. fix(config): treat empty boolean env vars as unset instead of True #5198 argued for "empty means unset, keep the default" and was closed by the stale bot before any review. I went the other way for the reason in fix(config): treat empty boolean env vars as unset instead of True #5198's own example:BROWSER_USE_CLOUD_SYNC's default isstr(self.ANONYMIZED_TELEMETRY), so treatingANONYMIZED_TELEMETRY=as unset resolves it back totrueand leaves telemetry on — the outcome that brings someone to write that line. If a maintainer prefers the other reading it is a one-line change in the helper; say so and I'll rework it.Testing
Added
test_empty_boolean_env_vars_are_falsetoTestLazyConfigintests/ci/infrastructure/test_config.py, alongside the existing env-var tests and in the same save/restore style. It covers five of the six properties;IN_DOCKERis left out because it ORs inis_running_in_docker(), whose answer depends on the machine rather than on the parse.Fails before the fix, passes after:
Whole
tests/ci/infrastructuredirectory, same branch, source only flipped:Exactly one test flips and it is the new one. The remaining failure is
TestLazyConfig::test_path_configuration, which fails identically on unmodifiedmainin this checkout.CI's lint jobs:
uv run ruff check --no-fix --select PLE browser_use/config.py tests/ci/infrastructure/test_config.py→All checks passed!ruff checkwith the repo config on the same two files →All checks passed!codespellon the same two files → no findingsruff format --check→ clean. Worth flagging how I checked this, because it initially looked red: run against the working-tree files it reports "would be reformatted", and so does unmodifiedmain—core.autocrlfgives this checkout CRLF files. Against LF-normalised copies of the same two files it reports2 files already formatted, so the complaint is the checkout, not the diff.pyright(joblint-typecheck) orpre-commit run --all-files:pre-commitandpyrightare not installed in the venv I used, andis_running_in_dockeris@cache-decorated and imported from the package, so a partial environment would have produced noise rather than signal. The type surface of this change isstr -> boolfromos.getenv, unchanged from what it replaced.Overlap with existing PRs
#5198,#4343and#4348proposed fixes for this exact line and were all closed by the stale bot with no human review (#5198had its CLA signed), so the defect is unfixed and unowned.#4837is the only open PR touching either file; itsconfig.pyhunk is confined tois_running_in_docker()and its test hunk appends to the end ofTestLazyConfig, so we share two filenames and zero changed lines.Additional notes
SKIP_LLM_API_KEY_VERIFICATION,BROWSER_USE_CLOUD_SYNC) become harder to enable by accident, not easier.d8110c5and pasted its own output. No human reviewed the diff before it was opened, and the commit carries no AI co-author trailer. Note that browser-use merges require a signed CLA, which the account owner has not yet signed — happy to do that step once it is.Summary by cubic
Fixes #5837. Empty boolean env vars (e.g.
ANONYMIZED_TELEMETRY=in a.envfile or a docker-compose entry) previously parsed asTrueand switched telemetry, cloud sync, version checks, and other flags on; they now readFalse. Unset variables keep their existing defaults, and all other spellings parse exactly as before, so gate-keeping flags likeSKIP_LLM_API_KEY_VERIFICATIONandBROWSER_USE_CLOUD_SYNCare no longer accidentally enabled.Refactors
_env_bool()helper.test_empty_boolean_env_vars_are_false, covering five of the six properties;IN_DOCKERis excluded because it ORs inis_running_in_docker().Written for commit f8739d3. Summary will update on new commits.