Skip to content

fixed extraction - #1

Merged
gregpr07 merged 1 commit into
mainfrom
gregorzunic/int-10-top-element-function-is-fucked
Nov 4, 2024
Merged

gregpr07 merged 1 commit into
mainfrom
gregorzunic/int-10-top-element-function-is-fucked

Conversation

@gregpr07

@gregpr07 gregpr07 commented Nov 4, 2024

Copy link
Copy Markdown
Member

No description provided.

@gregpr07
gregpr07 merged commit 4e01908 into main Nov 4, 2024
@gregpr07
gregpr07 deleted the gregorzunic/int-10-top-element-function-is-fucked branch November 4, 2024 15:32
MagMueller pushed a commit that referenced this pull request Nov 15, 2024
tan-t added a commit to tan-t/browser-use that referenced this pull request Jan 2, 2025
…735745006-add-agent-server-api

feat: Add FastAPI server for agent execution
pirate pushed a commit that referenced this pull request Apr 22, 2025
…osition

Fix: Ensure first element is correctly indexed in sibling list
dharam1291 pushed a commit to dharam1291/browser-use that referenced this pull request May 3, 2025
…t-element-position

Fix: Ensure first element is correctly indexed in sibling list
az-rye pushed a commit to rye-com/browser-use that referenced this pull request Aug 8, 2025
Fix: workflow runner works with new schema definition
Diveyam-Mishra added a commit to Diveyam-Mishra/browser-use that referenced this pull request Aug 13, 2025
…action-improvements

Improve Initial Action Handling
@Resanso

Resanso commented Aug 29, 2025

Copy link
Copy Markdown

Error 401: No auth credentials found when trying to use the DeepSeek model with OpenRouter API. Please check if the API key is correctly set and accessible in the environment variables.

MagMueller added a commit that referenced this pull request Oct 30, 2025
…c placeholder

- Changed the image placeholder format from a numbered format (e.g., '[Image #1]') to a single generic placeholder ('[Image]') for consistency and simplicity in the result text processing.
shashank-100 added a commit to shashank-100/browser-use that referenced this pull request Nov 14, 2025
Implemented two versions of Zillow agent scraper:

1. zillow_agent_scraper.py (Playwright-based):
   - Uses Chrome CDP for bot detection bypass
   - Clicks show phone/email buttons
   - Extracts comprehensive agent data

2. zillow_scraper_simple.py (HTTP-based - RECOMMENDED):
   - Direct HTML parsing with httpx + BeautifulSoup
   - Requires browser cookies for authentication
   - 100% email/phone extraction success rate
   - Incremental CSV writing for real-time progress
   - Supports multi-page scraping

Features:
- Email extraction (priority browser-use#1) from mailto: links
- Phone extraction from tel: links
- Agent details: name, rating, reviews, sales, specialties
- Brokerage, license, website, bio extraction
- CSV export with all fields
- Human-like delays to avoid rate limiting

Usage:
python zillow_scraper_simple.py \
  --url "https://www.zillow.com/professionals/real-estate-agent-reviews/los-angeles-ca/" \
  --max-agents 50 \
  --max-pages 10 \
  --cookies zillow_cookies.txt \
  --output "agents.csv"

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
mertunsall pushed a commit that referenced this pull request Nov 26, 2025
MagMueller referenced this pull request in MagMueller/browser-use Apr 1, 2026
_parse_rare_boolean_data used `index in list` (O(n) per call) on the
isClickable rare boolean data. Called once per node, this was O(n²)
total — the #1 bottleneck in the entire pipeline.

Fix: convert the list to a set once before the loop. O(1) per lookup.

Before → After:
  5k elements:  1,788ms →   768ms  (2.3x)
  20k elements: 16,819ms → 2,911ms (5.8x)
  100k elements: 356,629ms → 9,224ms (38.7x)

This single fix makes the full pipeline 2-3x faster at every scale:
  5k:  8.0s → ~3.8s
  20k: 29.7s → ~16s
  100k: impossible → ~20s (Chrome-limited, not Python-limited)
sauravpanda added a commit that referenced this pull request Apr 21, 2026
…nd_raw

Two P2 comments from cubic on 9a09c4d:

1. TimeoutWrappedCDPClient.__init__ trusted its cdp_request_timeout_s arg
   blindly. nan / inf / <=0 would either make every CDP call time out
   immediately (nan) or disable the guard (inf / <=0) — same defensive
   gap we already fixed for the env-var path. Extracted _coerce_valid_
   timeout() that mirrors _parse_env_cdp_timeout's validation; constructor
   now routes through it, so both entry points are equally safe.

2. test_send_raw_times_out_on_silent_server used an inline copy of the
   wrapper logic rather than the real TimeoutWrappedCDPClient.send_raw.
   A regression in the production method — e.g. accidentally removing
   the asyncio.wait_for — would not fail the test. Rewrote to:
   - Construct via __new__ (skip CDPClient.__init__'s WebSocket setup)
   - unittest.mock.patch the parent CDPClient.send_raw with a hanging
     coroutine
   - Call the real TimeoutWrappedCDPClient.send_raw, which does
     super().send_raw(...) → our patched stub
   - Assert it raises TimeoutError within the cap

Also added test_send_raw_passes_through_when_fast (fast-path regression
guard) and test_constructor_rejects_invalid_timeout (validation for
fix #1). All 14 tests in the timeout suite pass locally.
soyun11 pushed a commit to soyun11/browser-use that referenced this pull request May 15, 2026
…t-element-position

Fix: Ensure first element is correctly indexed in sibling list
soyun11 pushed a commit to soyun11/browser-use that referenced this pull request May 15, 2026
…c placeholder

- Changed the image placeholder format from a numbered format (e.g., '[Image browser-use#1]') to a single generic placeholder ('[Image]') for consistency and simplicity in the result text processing.
soyun11 pushed a commit to soyun11/browser-use that referenced this pull request May 15, 2026
sauravpanda added a commit that referenced this pull request May 23, 2026
## Context

Closes part of #4887 (item #1 — make the per-step transcript
append-only).

For Gemini's implicit cache (and similar provider caches) to actually
hit step over step, the rendered transcript for steps 1..N-1 must be
byte-identical at step N and at step N+1. The agent today appends
`HistoryItem`s immutably in practice — every site I checked constructs a
new item and `.append()`s it — but nothing in the type itself prevents a
future caller from mutating one in place. That kind of mutation would
silently kill the cache from that byte onward, and we'd only notice it
as a slow erosion of cached-token-ratio.

## Change

1. Mark `HistoryItem` `frozen=True` via pydantic `ConfigDict`, so any
mutation fails loud at runtime instead of silently burning input tokens
later.
2. Add a regression test set
(`tests/ci/test_history_item_byte_stable.py`) that asserts the cache
property directly:
- `render(items[:N])` is a strict byte-prefix of `render(items[:N+1])`
   - `to_string()` is deterministic for identical inputs
- the prefix property holds across mixed entry shapes (normal steps,
errors, system messages, follow-up tasks)
- conditional field inclusion in `to_string()` doesn't collapse to
ambiguous output (a populated field shouldn't render identically to a
missing one)

The tests pass against current behavior — they're locking it down, not
changing it.

## Known limitation (intentionally not in this PR)

`MessageManager.agent_history_description` does have one real
cache-buster I noticed during the audit: when `max_history_items` is set
and exceeded, the compaction logic at
`message_manager/service.py:173-186` rewrites earlier bytes — the `[...
N previous steps omitted...]` count changes every step past the cap, so
the prefix is not stable past the boundary.

Fixing that properly means either (a) capping the omitted-count at a
stable value, or (b) restructuring the compaction to omit at a fixed
cutoff. Either way it's a bigger design call than this hygiene PR, so I
left it for a follow-up. Calling it out in the commit message.

## Test plan

- [x] New byte-stability tests pass (`pytest
tests/ci/test_history_item_byte_stable.py`).
- [x] Existing message_manager / history tests still pass (`pytest
tests/ci -k 'message_manager or history'`).
- [x] `pyright` + `ruff` clean via pre-commit.

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Freeze `HistoryItem` to make agent step transcripts append-only and
preserve byte-prefix stability for provider caches (e.g., Gemini). Adds
regression tests to lock deterministic rendering and strict prefix
growth. Part of #4887.

- **Refactors**
- Set `frozen=True` in `pydantic` `ConfigDict` for `HistoryItem`;
mutation now raises instead of silently changing rendered bytes.
- Added regression tests to enforce: strict byte-prefix growth across
steps, deterministic `to_string()`, stability with mixed entry shapes,
and disambiguation of optional fields.

<sup>Written for commit 8236cc7.
Summary will update on new commits. <a
href="https://cubic.dev/pr/browser-use/browser-use/pull/4890?utm_source=github">Review
in cubic</a></sup>

<!-- End of auto-generated description by cubic. -->
r266-tech pushed a commit to r266-tech/browser-use that referenced this pull request May 26, 2026
…er-use#4890)

## Context

Closes part of browser-use#4887 (item browser-use#1 — make the per-step transcript
append-only).

For Gemini's implicit cache (and similar provider caches) to actually
hit step over step, the rendered transcript for steps 1..N-1 must be
byte-identical at step N and at step N+1. The agent today appends
`HistoryItem`s immutably in practice — every site I checked constructs a
new item and `.append()`s it — but nothing in the type itself prevents a
future caller from mutating one in place. That kind of mutation would
silently kill the cache from that byte onward, and we'd only notice it
as a slow erosion of cached-token-ratio.

## Change

1. Mark `HistoryItem` `frozen=True` via pydantic `ConfigDict`, so any
mutation fails loud at runtime instead of silently burning input tokens
later.
2. Add a regression test set
(`tests/ci/test_history_item_byte_stable.py`) that asserts the cache
property directly:
- `render(items[:N])` is a strict byte-prefix of `render(items[:N+1])`
   - `to_string()` is deterministic for identical inputs
- the prefix property holds across mixed entry shapes (normal steps,
errors, system messages, follow-up tasks)
- conditional field inclusion in `to_string()` doesn't collapse to
ambiguous output (a populated field shouldn't render identically to a
missing one)

The tests pass against current behavior — they're locking it down, not
changing it.

## Known limitation (intentionally not in this PR)

`MessageManager.agent_history_description` does have one real
cache-buster I noticed during the audit: when `max_history_items` is set
and exceeded, the compaction logic at
`message_manager/service.py:173-186` rewrites earlier bytes — the `[...
N previous steps omitted...]` count changes every step past the cap, so
the prefix is not stable past the boundary.

Fixing that properly means either (a) capping the omitted-count at a
stable value, or (b) restructuring the compaction to omit at a fixed
cutoff. Either way it's a bigger design call than this hygiene PR, so I
left it for a follow-up. Calling it out in the commit message.

## Test plan

- [x] New byte-stability tests pass (`pytest
tests/ci/test_history_item_byte_stable.py`).
- [x] Existing message_manager / history tests still pass (`pytest
tests/ci -k 'message_manager or history'`).
- [x] `pyright` + `ruff` clean via pre-commit.

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Freeze `HistoryItem` to make agent step transcripts append-only and
preserve byte-prefix stability for provider caches (e.g., Gemini). Adds
regression tests to lock deterministic rendering and strict prefix
growth. Part of browser-use#4887.

- **Refactors**
- Set `frozen=True` in `pydantic` `ConfigDict` for `HistoryItem`;
mutation now raises instead of silently changing rendered bytes.
- Added regression tests to enforce: strict byte-prefix growth across
steps, deterministic `to_string()`, stability with mixed entry shapes,
and disambiguation of optional fields.

<sup>Written for commit 8236cc7.
Summary will update on new commits. <a
href="https://cubic.dev/pr/browser-use/browser-use/pull/4890?utm_source=github">Review
in cubic</a></sup>

<!-- End of auto-generated description by cubic. -->

@Rahwulkumar Rahwulkumar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

noop

sauravpanda added a commit that referenced this pull request Jun 28, 2026
…resume (ENG-5280) (#5086)

## Problem

The V2 worker reuses a `keep_alive` `BrowserSession` across warm Lambda
invocations. At the end of a run, `Agent.close()` stops the session's
event bus and nulls out its async primitives (`event_queue` /
`_on_idle`) to release the event loop (the "fix keep-alive hang"
change).

On a warm resume, the worker can `step()` that bus *before* any
`dispatch()` restarts it. In that torn-down state, stock `bubus`
`EventBus.step()` hits:

```
AssertionError: EventBus._start() must be called before step()
```

The crash is deterministic (not transient), so retries don't recover and
the task dead-letters after max receives — ~1,600+ occurrences over 2
days per the DLQ.

## Root cause

The nulling in `Agent.close()` is *load-bearing*: it's what lets the
next `dispatch()` recreate a fresh queue and `_start()` the bus again
(bubus `_start()` only recreates the queue when `event_queue is None`).
So we can't simply stop nulling — but a nulled bus is exactly the state
where `step()` / `wait_until_idle()` assert.

## Fix

Wrap the session's event bus in a small `ResilientEventBus(EventBus)`
subclass whose `step()` and `wait_until_idle()` are **safe no-ops when
the bus has not been started**, instead of asserting. Teardown is
unchanged, so a later `dispatch()` still recreates the queue and
restarts the bus normally.

This is the browser-use-level equivalent of the issue's suggested fix #1
("patch bubus so `step()` tolerates a stopped/unstarted bus"), scoped to
the bus that actually gets torn down.

## Verification

`tests/ci/test_event_bus_resilience.py`:
- the session's default `event_bus` is a `ResilientEventBus`
- `step()` / `wait_until_idle()` on a stopped + nulled bus return `None`
(no `AssertionError`)
- a torn-down bus still restarts and processes events on the next
`dispatch()`
- a stock `EventBus` still reproduces the original assertion (documents
the upstream bug)

All 4 pass; `pyright` and `ruff` clean.

Fixes ENG-5280.

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Tolerate stepping a torn-down event bus on warm-Lambda resumes to
prevent deterministic worker crashes and DLQs. The session now uses a
resilient event bus that no-ops until the next `dispatch()` restarts it.
Fixes ENG-5280.

- **Bug Fixes**
- Added `ResilientEventBus(EventBus)` that makes `step()` and
`wait_until_idle()` no-ops when `_on_idle` or `event_queue` is `None`.
- Made `BrowserSession.event_bus` use `ResilientEventBus` by default and
in `kill()`/`stop()`, and kept default bus names as `EventBus_*`
(explicit names still honored).
- Added `tests/ci/test_event_bus_resilience.py` to verify no-op
behavior, restart on `dispatch()`, name prefix preservation, and to
document the upstream `bubus.EventBus` assertion.
- Tightened `ResilientEventBus` docstrings and comments (no behavior
change).

<sup>Written for commit 5123e4f.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/browser-use/browser-use/pull/5086?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->
sauravpanda added a commit to primorLee/browser-use that referenced this pull request Aug 24, 2026
… absent

`'#' not in extracted_text` claimed more than the renderer promises: only
a leading `# `/`## `/`### ` marker is stripped, hashes anywhere else are
plain text. Assert each header's source line is gone and its rendered
text survives, and cover a literal `browser-use#1` in header content.
sauravpanda added a commit to primorLee/browser-use that referenced this pull request Aug 24, 2026
A substring check passes with a leftover marker: 'Notes <i> browser-use#1' matches
inside '# Notes <i> browser-use#1', so an H3 branch using the H1 offset would slip
through. Compare against whole extracted lines instead, and cover the
gaps that turned up alongside it: a non-header line starting with '#'
(pins the 'startswith("# ")' boundary against an lstrip-style rewrite)
and quote characters (html.escape emits &#x27;/&quot;, which ReportLab
must unescape back). Rename to match what the test now covers.
eddyflores100-lang pushed a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…-closed + 6 P2 fixes)

Addresses all 7 issues raised by cubic-dev-ai[bot] in its review on
PR browser-use#6226 (review run 978321d8-5481-5e5a-baa4-f7acfa7415cb).

P1 — filter_trusted trusts on lookup exception (trust.py:147)
  filter_trusted used to append a URL to trusted[] when its lookup
  raised and allow_unknown=True. That is wrong: allow_unknown applies
  ONLY to explicit TrustVerdict(score=None) results. A lookup that
  raised did not produce a verdict, so the server must not be trusted.
  Lookup exceptions are now ALWAYS fail-closed, regardless of
  allow_unknown. The class docstring spells this out.
  New test: test_lookup_exception_is_fail_closed_even_with_allow_unknown.

P2 browser-use#1 — inclusive threshold not tested (test_trust.py:11)
  Added test_threshold_is_inclusive_at_boundary that asserts a verdict
  with score=0.7 against min_score=0.7 is trusted. Locks down the >=
  comparison so an accidental switch to > would fail CI.

P2 browser-use#2 — Ruff double-quote style (test_trust.py:14)
  All new string literals switched to single quotes to match the
  repo's Ruff config. Ran 'ruff format' on both files; clean.

P2 browser-use#3 — credentials in lookup URL (trust.py:64)
  Added _strip_credentials_from_url that drops userinfo (user:pass@)
  and secret-bearing query parameters (api_key, token, access_token,
  secret, password, auth) before the URL is sent to the third-party
  trust API. Non-secret query params (page, etc.) are preserved.
  New test: test_strip_credentials_from_url covers userinfo, secret
  query, non-secret query, and port preservation.

P2 browser-use#4 — out-of-range scores (trust.py:75)
  Score validation now rejects NaN, inf, and any value outside
  [0.0, 100.0] before normalizing. A score=200 would previously
  normalize to 2.0 and pass any threshold <= 1.0. String scores
  ('0.85') are coerced to float; non-numeric strings are rejected.
  New test: test_default_lookup_rejects_out_of_range_score.

P2 browser-use#5 — malformed 200 escapes (trust.py:82)
  The except clause now catches ValueError, TypeError, AttributeError
  in addition to httpx.RequestError and asyncio.TimeoutError. A 200
  response with malformed JSON or a non-object body returns a fail-
  closed verdict with a reason, instead of raising out of check().
  New test: test_default_lookup_handles_malformed_200.

P2 browser-use#6 — TrustChecker not wired into agent (trust.py:95)
  Not fixed in this PR by design: keeping the change small and
  reviewable. The PR title and docstring already describe the module
  as a standalone helper. A follow-up PR will wire it into the MCP
  client connection path. Reply in the review thread.

Tests: 11 pass, 0 fail. Ruff check + format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
eddyflores100-lang added a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…-closed + 6 P2 fixes)

Addresses all 7 issues raised by cubic-dev-ai[bot] in its review on
PR browser-use#6226 (review run 978321d8-5481-5e5a-baa4-f7acfa7415cb).

P1 — filter_trusted trusts on lookup exception (trust.py:147)
  filter_trusted used to append a URL to trusted[] when its lookup
  raised and allow_unknown=True. That is wrong: allow_unknown applies
  ONLY to explicit TrustVerdict(score=None) results. A lookup that
  raised did not produce a verdict, so the server must not be trusted.
  Lookup exceptions are now ALWAYS fail-closed, regardless of
  allow_unknown. The class docstring spells this out.
  New test: test_lookup_exception_is_fail_closed_even_with_allow_unknown.

P2 browser-use#1 — inclusive threshold not tested (test_trust.py:11)
  Added test_threshold_is_inclusive_at_boundary that asserts a verdict
  with score=0.7 against min_score=0.7 is trusted. Locks down the >=
  comparison so an accidental switch to > would fail CI.

P2 browser-use#2 — Ruff double-quote style (test_trust.py:14)
  All new string literals switched to single quotes to match the
  repo's Ruff config. Ran 'ruff format' on both files; clean.

P2 browser-use#3 — credentials in lookup URL (trust.py:64)
  Added _strip_credentials_from_url that drops userinfo (user:pass@)
  and secret-bearing query parameters (api_key, token, access_token,
  secret, password, auth) before the URL is sent to the third-party
  trust API. Non-secret query params (page, etc.) are preserved.
  New test: test_strip_credentials_from_url covers userinfo, secret
  query, non-secret query, and port preservation.

P2 browser-use#4 — out-of-range scores (trust.py:75)
  Score validation now rejects NaN, inf, and any value outside
  [0.0, 100.0] before normalizing. A score=200 would previously
  normalize to 2.0 and pass any threshold <= 1.0. String scores
  ('0.85') are coerced to float; non-numeric strings are rejected.
  New test: test_default_lookup_rejects_out_of_range_score.

P2 browser-use#5 — malformed 200 escapes (trust.py:82)
  The except clause now catches ValueError, TypeError, AttributeError
  in addition to httpx.RequestError and asyncio.TimeoutError. A 200
  response with malformed JSON or a non-object body returns a fail-
  closed verdict with a reason, instead of raising out of check().
  New test: test_default_lookup_handles_malformed_200.

P2 browser-use#6 — TrustChecker not wired into agent (trust.py:95)
  Not fixed in this PR by design: keeping the change small and
  reviewable. The PR title and docstring already describe the module
  as a standalone helper. A follow-up PR will wire it into the MCP
  client connection path. Reply in the review thread.

Tests: 11 pass, 0 fail. Ruff check + format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
eddyflores100-lang added a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…-closed + 6 P2 fixes)

Addresses all 7 issues raised by cubic-dev-ai[bot] in its review on
PR browser-use#6226 (review run 978321d8-5481-5e5a-baa4-f7acfa7415cb).

P1 — filter_trusted trusts on lookup exception (trust.py:147)
  filter_trusted used to append a URL to trusted[] when its lookup
  raised and allow_unknown=True. That is wrong: allow_unknown applies
  ONLY to explicit TrustVerdict(score=None) results. A lookup that
  raised did not produce a verdict, so the server must not be trusted.
  Lookup exceptions are now ALWAYS fail-closed, regardless of
  allow_unknown. The class docstring spells this out.
  New test: test_lookup_exception_is_fail_closed_even_with_allow_unknown.

P2 browser-use#1 — inclusive threshold not tested (test_trust.py:11)
  Added test_threshold_is_inclusive_at_boundary that asserts a verdict
  with score=0.7 against min_score=0.7 is trusted. Locks down the >=
  comparison so an accidental switch to > would fail CI.

P2 browser-use#2 — Ruff double-quote style (test_trust.py:14)
  All new string literals switched to single quotes to match the
  repo's Ruff config. Ran 'ruff format' on both files; clean.

P2 browser-use#3 — credentials in lookup URL (trust.py:64)
  Added _strip_credentials_from_url that drops userinfo (user:pass@)
  and secret-bearing query parameters (api_key, token, access_token,
  secret, password, auth) before the URL is sent to the third-party
  trust API. Non-secret query params (page, etc.) are preserved.
  New test: test_strip_credentials_from_url covers userinfo, secret
  query, non-secret query, and port preservation.

P2 browser-use#4 — out-of-range scores (trust.py:75)
  Score validation now rejects NaN, inf, and any value outside
  [0.0, 100.0] before normalizing. A score=200 would previously
  normalize to 2.0 and pass any threshold <= 1.0. String scores
  ('0.85') are coerced to float; non-numeric strings are rejected.
  New test: test_default_lookup_rejects_out_of_range_score.

P2 browser-use#5 — malformed 200 escapes (trust.py:82)
  The except clause now catches ValueError, TypeError, AttributeError
  in addition to httpx.RequestError and asyncio.TimeoutError. A 200
  response with malformed JSON or a non-object body returns a fail-
  closed verdict with a reason, instead of raising out of check().
  New test: test_default_lookup_handles_malformed_200.

P2 browser-use#6 — TrustChecker not wired into agent (trust.py:95)
  Not fixed in this PR by design: keeping the change small and
  reviewable. The PR title and docstring already describe the module
  as a standalone helper. A follow-up PR will wire it into the MCP
  client connection path. Reply in the review thread.

Tests: 11 pass, 0 fail. Ruff check + format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
eddyflores100-lang added a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…n, CancelledError (cubic-dev-ai review round 2)

Addresses the 5 new issues raised by cubic-dev-ai[bot] in its second
and third reviews on PR browser-use#6226 (2026-11-06 01:54 and 02:05), all against
the recent commits that fixed the original 7 issues.

P1 browser-use#4 (trust.py:259, review 2026-11-06 01:54) — filter_trusted logs raw URLs
  filter_trusted's warning and info log lines logged the raw server_url,
  so credentials embedded in a URL (e.g. https://user:pass@host?api_key=...)
  reached application logs even though the API request had them stripped.
  Added _redact_url_for_logging helper that strips userinfo and secret
  query params before logging; both warning and info paths now use it.
  Two new tests: test_filter_trusted_logs_redacted_url_on_exception and
  test_filter_trusted_logs_redacted_url_on_skip — both assert the raw
  URL never appears in caplog.text.

P2 browser-use#1 (trust.py:69) — IPv6 brackets dropped by sanitizer
  _strip_credentials_from_url used parts.hostname, which strips the
  brackets from an IPv6 address; urlunsplit then produced a malformed
  URL (the colon in the IPv6 address is ambiguous with the port
  separator). Re-add brackets around colon-containing hostnames before
  building the netloc.
  New test: test_strip_credentials_preserves_ipv6_brackets covers
  [::1]:8443 and [2001:db8::1] cases.

P2 browser-use#2 (trust.py:70) — invalid port escapes sanitizer
  parts.port raises ValueError on a malformed port substring like
  'abc' (e.g. https://host:abc/). That ValueError escaped the sanitizer
  and the lookup raised before the fail-closed handler could catch it.
  Wrapped parts.port access in try/except (ValueError, TypeError) and
  treat invalid port as no port.
  New test: test_strip_credentials_handles_invalid_port asserts the
  sanitizer returns a URL without :abc and does not raise.

P2 browser-use#3 (trust.py:139) — score validator accepts JSON booleans
  bool is a subclass of int in Python, so isinstance(True, int) is
  True and float(True) returns 1.0. A JSON `true` in the trust_score
  field would normalize to 1.0 and pass any threshold <= 1.0. Added
  an explicit isinstance(score, bool) check before numeric coercion
  that rejects booleans with a fail-closed verdict.
  New test: test_default_lookup_rejects_boolean_score asserts the
  verdict has score=None and the reason mentions 'boolean'.

P2 browser-use#5 (trust.py:256, review 2026-11-06 02:05) — BaseException reaches cast
  asyncio.gather with return_exceptions=True returns List[TrustVerdict |
  BaseException]. The isinstance(result, Exception) guard only catches
  Exception subclasses, not BaseException. A CancelledError (which is a
  BaseException since Python 3.8) reached the cast and crashed with
  AttributeError on verdict.is_trusted instead of preserving the
  cancellation. Now we re-raise asyncio.CancelledError and any other
  BaseException that isn't an Exception subclass (KeyboardInterrupt,
  SystemExit) before the cast.
  New test: test_filter_trusted_propagates_cancelled_error asserts that
  a CancelledError raised by the lookup propagates instead of being
  swallowed as fail-closed.

Tests: 17 pass, 0 fail (was 11, +6 new). pyright clean. ruff format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants