From fe21ee229e5e9cc633fc6f79c60f089f19fbc710 Mon Sep 17 00:00:00 2001 From: tkattkat Date: Tue, 17 Mar 2026 16:00:39 -0700 Subject: [PATCH] Fix AttributeError crash from calling nonexistent `warning` method on StagehandLogger --- .changeset/prehistoric-fluffy-sturgeon.md | 5 +++++ stagehand/context.py | 2 +- stagehand/main.py | 4 ++-- stagehand/page.py | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/prehistoric-fluffy-sturgeon.md diff --git a/.changeset/prehistoric-fluffy-sturgeon.md b/.changeset/prehistoric-fluffy-sturgeon.md new file mode 100644 index 00000000..3f48ebbf --- /dev/null +++ b/.changeset/prehistoric-fluffy-sturgeon.md @@ -0,0 +1,5 @@ +--- +"stagehand": patch +--- + +Fix AttributeError crash from calling nonexistent `warning` method on StagehandLogger diff --git a/stagehand/context.py b/stagehand/context.py index 27ee327a..de9ddfcc 100644 --- a/stagehand/context.py +++ b/stagehand/context.py @@ -164,7 +164,7 @@ async def handle_with_lock(): category="context", ) else: - self.stagehand.logger.warning( + self.stagehand.logger.debug( "Could not find StagehandPage wrapper for remaining page", category="context", ) diff --git a/stagehand/main.py b/stagehand/main.py index 4f161d92..44bba0bc 100644 --- a/stagehand/main.py +++ b/stagehand/main.py @@ -563,7 +563,7 @@ async def init(self): ) self.logger.debug("Set up CDP download behavior") except Exception as e: - self.logger.warning(f"Failed to set up CDP download behavior: {str(e)}") + self.logger.debug(f"Failed to set up CDP download behavior: {str(e)}") self._initialized = True @@ -618,7 +618,7 @@ async def close(self): f"Error ending server session {self.session_id}: {str(e)}" ) elif self.session_id: - self.logger.warning( + self.logger.debug( "Cannot end server session: HTTP client not available." ) diff --git a/stagehand/page.py b/stagehand/page.py index eb88148e..7237aab9 100644 --- a/stagehand/page.py +++ b/stagehand/page.py @@ -77,7 +77,7 @@ async def ensure_injection(self): # Ensure that the script is injected on future navigations await self._page.add_init_script(_INJECTION_SCRIPT) except TargetClosedError as e: - self._stagehand.logger.warning( + self._stagehand.logger.debug( f"ensure_injection failed (page may be navigating): {e}", category="page", )