fix(browser_tool): fall through to autodetect on config read failure
This commit is contained in:
committed by
Teknium
parent
3170c8d448
commit
48bf0ea249
@@ -10,7 +10,7 @@ All other ``None`` outcomes (no credentials yet, config read error, explicit
|
|||||||
provider instantiation failure) leave the cache unset so the next call retries.
|
provider instantiation failure) leave the cache unset so the next call retries.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|||||||
@@ -447,19 +447,24 @@ def _get_cloud_provider() -> Optional[CloudBrowserProvider]:
|
|||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
# Config file may be temporarily unreadable; still try auto-detect so
|
||||||
|
# env-based / managed-gateway credentials can resolve. Don't pin cache.
|
||||||
logger.debug("Could not read cloud_provider from config: %s", e)
|
logger.debug("Could not read cloud_provider from config: %s", e)
|
||||||
return None
|
|
||||||
|
|
||||||
if resolved is None:
|
if resolved is None:
|
||||||
# Prefer Browser Use (managed Nous gateway or direct API key),
|
# Prefer Browser Use (managed Nous gateway or direct API key),
|
||||||
# fall back to Browserbase (direct credentials only).
|
# fall back to Browserbase (direct credentials only).
|
||||||
fallback_provider = BrowserUseProvider()
|
try:
|
||||||
if fallback_provider.is_configured():
|
fallback_provider = BrowserUseProvider()
|
||||||
resolved = fallback_provider
|
|
||||||
else:
|
|
||||||
fallback_provider = BrowserbaseProvider()
|
|
||||||
if fallback_provider.is_configured():
|
if fallback_provider.is_configured():
|
||||||
resolved = fallback_provider
|
resolved = fallback_provider
|
||||||
|
else:
|
||||||
|
fallback_provider = BrowserbaseProvider()
|
||||||
|
if fallback_provider.is_configured():
|
||||||
|
resolved = fallback_provider
|
||||||
|
except Exception: # pragma: no cover - defensive: never poison cache
|
||||||
|
logger.debug("Cloud provider auto-detect failed", exc_info=True)
|
||||||
|
return None
|
||||||
|
|
||||||
if resolved is None:
|
if resolved is None:
|
||||||
# Transient None — credentials may self-heal. Don't poison the cache.
|
# Transient None — credentials may self-heal. Don't poison the cache.
|
||||||
|
|||||||
Reference in New Issue
Block a user