Bug: an exception without a message gives an empty error in the log and for the model · Issue #5975 · browser-use/browser-use · GitHub
Skip to content

Bug: an exception without a message gives an empty error in the log and for the model #5975

Open

Description

@HardMax71

Browser Use Version

0.13.10 and main at 302d8fc

Bug Description, Steps to Reproduce, Screenshots

When an action or a step fails with an exception that has no message, such as TimeoutError(), ConnectionError() or a failed bare assert, browser-use formats it with str(e), which is empty:

  • navigate logs ❌ Navigation failed: and returns ActionResult(error='Navigation failed: ') (tools/service.py#L555-L558, #L581); search does the same (#L498-L500).
  • AgentError.format_error returns '' (agent/views.py#L966, #L980-L982), so _handle_step_error logs ❌ Result failed 1/6 times: with nothing after the colon and puts an empty error into the next prompt.

Neither the log nor the model gets the exception type. I see these empty lines in a production app. session.py already logs the type for the same navigation failure (Navigation failed: {type(e).__name__}: {e}, session.py#L1005); the action and the agent do not.

Repro: format_error directly, then navigate on headless Chromium with _navigate_and_wait replaced by a function that raises ConnectionError().

Failing Python Code

import asyncio
from importlib.metadata import version

from browser_use.agent.views import AgentError
from browser_use.browser import BrowserProfile, BrowserSession
from browser_use.tools.service import Tools


async def drop_connection(*args, **kwargs):
	raise ConnectionError()  # stands in for any failure raised without a message


async def main() -> None:
	print('browser-use', version('browser-use'))
	for error in (TimeoutError(), ConnectionError(), AssertionError()):
		print(f'AgentError.format_error({type(error).__name__}()) = {AgentError.format_error(error)!r}')

	session = BrowserSession(browser_profile=BrowserProfile(headless=True, user_data_dir=None, enable_default_extensions=False))
	await session.start()
	BrowserSession._navigate_and_wait = drop_connection
	result = await Tools().navigate(url='http://127.0.0.1:9/', new_tab=False, browser_session=session)
	print('navigate ActionResult.error =', repr(result.error))
	await session.kill()


asyncio.run(main())

LLM Model

None (no agent or LLM involved)

Operating System & Browser Versions

macOS, Python 3.11, Playwright Chromium (headless)

Full DEBUG Log Output

browser-use 0.13.10
AgentError.format_error(TimeoutError()) = ''
AgentError.format_error(ConnectionError()) = ''
AgentError.format_error(AssertionError()) = ''
ERROR    [BrowserSession] ❌ Navigation failed: 
navigate ActionResult.error = 'Navigation failed: '

Expected: the exception type when the message is empty, e.g. Navigation failed: ConnectionError and TimeoutError from format_error.

Fix: str(e) or type(e).__name__ in those places. PR follows.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions