Skip to content

fix: ensure failed actions return errors instead of successes - #5390

Closed
shotsan wants to merge 2 commits into
browser-use:mainfrom
shotsan:fix/issue-5361-action-error-reporting
Closed

shotsan wants to merge 2 commits into
browser-use:mainfrom
shotsan:fix/issue-5361-action-error-reporting

Conversation

@shotsan

@shotsan shotsan commented Aug 4, 2026 •

Copy link
Copy Markdown

Fixes #5361. \n\nThis PR fixes three cases where actions that completely failed were silently returning success:\n1. scroll: Now tracks failed scrolls and correctly returns an error when no scrolls succeeded, rather than silently returning a successful ActionResult.\n2. input: Now properly returns an error ActionResult(error=msg) rather than a success ActionResult(extracted_content=msg) if the element index is not found.\n3. scroll_to_text: Differentiates between 'Text not found' (expected) and CDP/transport exceptions (unexpected) which now properly return an error.


Summary by cubic

Ensure failed actions return errors so callers can detect and handle failures reliably. Fixes #5361.

  • Bug Fixes
    • input: When the element index isn’t found, return ActionResult(error=msg) instead of a success with extracted_content.
    • scroll: If all scroll attempts fail, return ActionResult(error=...).
    • scroll_to_text: Use a structured BrowserError.details check to treat “text not found” as expected with a clear message; return errors for other browser/transport exceptions.

Written for commit 5bedbe6. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="browser_use/tools/service.py">

<violation number="1" location="browser_use/tools/service.py:1507">
P3: The new `find_text` handler branches control flow by checking whether the human-readable exception message contains the substring `'Text not found'`. This string-matching couples the tool to the exact wording of the error raised in `default_action_watchdog.on_ScrollToTextEvent` (`raise BrowserError(f'Text not found: "{event.text}"', details={'text': event.text})`). If that wording is ever reworded or localized, the 'expected' not-found case would silently fall through to `handle_browser_error`/the generic `except Exception` and be reported as a hard error — or worse, an unexpected CDP/transport error whose message happens to contain that substring would be swallowed as a benign 'not found'. Since `BrowserError` already carries structured metadata (the handler passes `details={'text': event.text}`), distinguishing expected vs unexpected failures via a structured marker (e.g., a dedicated exception subclass or a `details['reason'] == 'not_found'` check) would be far more robust than matching exception text.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread browser_use/tools/service.py Resolved
…text

Replace fragile 'Text not found' substring check on the exception message
with a structured check on e.details for the 'text' key. The ScrollToText
handler already passes details={'text': event.text} when raising
BrowserError, so this reliably distinguishes expected not-found errors
from unexpected browser failures without coupling to exception wording.

Addresses review feedback from cubic-dev-ai.
@github-actions

Copy link
Copy Markdown

👋 This PR has been automatically marked as stale because it hasn't had activity for 45 days.

To keep this PR open:

  • Rebase against the latest main branch
  • Address any review feedback or merge conflicts
  • Add a comment explaining the current status
  • Add the work-in-progress label if you're still actively working on this

This will be automatically closed in 14 days if no further activity occurs.

Thanks for contributing to browser-use! 🤖

@github-actions github-actions Bot added the stale label Sep 25, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

🔒 This PR was automatically closed because it was stale for 14 days with no activity.

Don't worry! If you'd like to continue this work:

  • Reopen this PR and rebase against main
  • Create a fresh PR with updated changes
  • Join our Discord if you need help

Thanks for contributing to browser-use! 🤖

@github-actions github-actions Bot closed this Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: scroll/input/scroll_to_text report failed actions as successes, so multi_act never aborts and consecutive_failures never increments

2 participants