aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Reinier van der Leer <pwuts@agpt.co> 2024-02-20 14:04:15 +0100
committerGravatar Reinier van der Leer <pwuts@agpt.co> 2024-02-20 14:04:15 +0100
commit7dd97f2f743c3fe48f6c62e0a2cc0c17171170a7 (patch)
tree8de794fa7c57ae7e1e23fe2e7d0989f224bc8ab9
parentfix(agent/llm): Include `id` in tool_calls in prompt (diff)
downloadAuto-GPT-7dd97f2f743c3fe48f6c62e0a2cc0c17171170a7.tar.gz
Auto-GPT-7dd97f2f743c3fe48f6c62e0a2cc0c17171170a7.tar.bz2
Auto-GPT-7dd97f2f743c3fe48f6c62e0a2cc0c17171170a7.zip
fix(agent/browser): Print descriptive error if ChromeDriver install fails
We have been seeing `AttributeError: 'NoneType' object has no attribute 'split'` in Sentry. According to https://github.com/SergeyPirogov/webdriver_manager/issues/649, this occurs when Chrome is not installed, or when no suitable ChromeDriver version is available for the installed version of Chrome. Instead of the `AttributeError`, we can print a better message for the agent and user to help them fix the issue. --- Co-authored-by: kcze <kpczerwinski@gmail.com>
-rw-r--r--autogpts/autogpt/autogpt/commands/web_selenium.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/autogpts/autogpt/autogpt/commands/web_selenium.py b/autogpts/autogpt/autogpt/commands/web_selenium.py
index fa5de1f17..59adb61b4 100644
--- a/autogpts/autogpt/autogpt/commands/web_selenium.py
+++ b/autogpts/autogpt/autogpt/commands/web_selenium.py
@@ -264,14 +264,21 @@ async def open_page_in_browser(url: str, config: Config) -> WebDriver:
_sideload_chrome_extensions(options, config.app_data_dir / "assets" / "crx")
- chromium_driver_path = Path("/usr/bin/chromedriver")
+ if (chromium_driver_path := Path("/usr/bin/chromedriver")).exists():
+ chrome_service = ChromeDriverService(str(chromium_driver_path))
+ else:
+ try:
+ chrome_driver = ChromeDriverManager().install()
+ except AttributeError as e:
+ if "'NoneType' object has no attribute 'split'" in str(e):
+ # https://github.com/SergeyPirogov/webdriver_manager/issues/649
+ logger.critical(
+ "Connecting to browser failed: is Chrome or Chromium installed?"
+ )
+ raise
+ chrome_service = ChromeDriverService(chrome_driver)
+ driver = ChromeDriver(service=chrome_service, options=options)
- driver = ChromeDriver(
- service=ChromeDriverService(str(chromium_driver_path))
- if chromium_driver_path.exists()
- else ChromeDriverService(ChromeDriverManager().install()),
- options=options,
- )
driver.get(url)
# Wait for page to be ready, sleep 2 seconds, wait again until page ready.