Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
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
…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.
|
👋 This PR has been automatically marked as stale because it hasn't had activity for 45 days. To keep this PR open:
This will be automatically closed in 14 days if no further activity occurs. Thanks for contributing to browser-use! 🤖 |
|
🔒 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:
Thanks for contributing to browser-use! 🤖 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 errorActionResult(error=msg)rather than a successActionResult(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 anerror.Summary by cubic
Ensure failed actions return errors so callers can detect and handle failures reliably. Fixes #5361.
input: When the element index isn’t found, returnActionResult(error=msg)instead of a success withextracted_content.scroll: If all scroll attempts fail, returnActionResult(error=...).scroll_to_text: Use a structuredBrowserError.detailscheck 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.