Repository navigation
Conversation
…mini#119) Fixes google-gemini#119 Previously, bool(os.environ.get('PLAYWRIGHT_HEADLESS', False)) evaluated any non-empty string as True because bool('false') is True in Python. Consequently, setting PLAYWRIGHT_HEADLESS=false (as shown in .env.example) caused Playwright to always run in headless mode. This aligns the boolean parsing with the existing pattern used in agent.py (os.environ.get(...).lower() in ['true', '1']), properly respecting false/0 values while maintaining default non-headless behavior when unset.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the evaluation of the 'PLAYWRIGHT_HEADLESS' environment variable to correctly parse string values like 'true' or '1' as booleans, and introduces unit tests to verify this behavior. The feedback recommends avoiding the use of 'clear=True' when patching 'os.environ' in tests, as clearing all environment variables can lead to unexpected side effects, and suggests specifically removing the target key instead.
|
Thanks @gemini-code-assist for the review! Addressed in commit 0944952. |
|
Thank you for the update. The changes look correct and the added unit tests provide good coverage for the environment variable parsing logic. The fix correctly addresses the issue where |
|
Commit reference: 0944952. Ready for maintainer merge. |
Update: Expanded Test Coverage & Clean DocumentationIn commit
All unit tests and repository status checks pass cleanly. Ready for maintainer review and merge. |
Description
Fixes #119.
In
computers/playwright/playwright.py,PLAYWRIGHT_HEADLESSwas parsed using:Because
os.environ.get()returns a string when set,bool("false")evaluates toTruein Python (any non-empty string is truthy). Consequently, settingPLAYWRIGHT_HEADLESS=falsein.env(which is the default in.env.example) caused the browser to always run in headless mode.Solution
agent.pyline 109:"false","0", and unset asFalsewhile respecting"true"and"1"asTrue.test_playwright.pycovering"false","true", and unset default cases.Verification
Ran all tests with pytest:
test_agent.py(11 passed)test_main.py(2 passed)test_playwright.py(3 passed)