Repository navigation
fix(extract): use actual content length in pagination error - #6253
user-Param wants to merge 14 commits into
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
|
def-Param seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
16 issues found across 16 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="skills/cloud/references/api-v2.md">
<violation number="1" location="skills/cloud/references/api-v2.md:193">
P2: This now incorrectly tells free users that they can request up to 240 minutes, even though the cloud request model still limits them to 15 minutes and rejects longer timeouts. Preserve the free-tier limit in this pricing description.</violation>
</file>
<file name="browser_use/llm/anthropic/serializer.py">
<violation number="1" location="browser_use/llm/anthropic/serializer.py:18">
P3: `ContentPartRefusalParam` is imported but never referenced, so the enabled F401 check will fail and pre-commit will try to remove it. Delete this import.</violation>
</file>
<file name="browser_use/filesystem/file_system.py">
<violation number="1" location="browser_use/filesystem/file_system.py:861">
P3: Preserve the auto-correction notice for internal images, matching the text-file path; otherwise reads such as `[email protected]` silently resolve to a different filename.</violation>
<violation number="2" location="browser_use/filesystem/file_system.py:862">
P2: This branch makes internal GIF and WebP files reach vision prompts, but the prompt formatter labels every non-PNG image as JPEG. Map `.gif` and `.webp` to their actual MIME types before sending these files to providers.</violation>
<violation number="3" location="browser_use/filesystem/file_system.py:862">
P2: Internal images retain the write tool’s trailing newline in `images[].data`, producing a non-canonical base64 data URL that image providers may reject. Strip base64 whitespace when constructing the image payload.</violation>
</file>
<file name="browser_use/browser/cloud/cloud.py">
<violation number="1" location="browser_use/browser/cloud/cloud.py:118">
P2: The 403 fallback now drops the actionable subscription guidance whenever the response has no usable `detail`; preserve the previous fallback message and append the server detail when one is available.</violation>
</file>
<file name="browser_use/browser/session.py">
<violation number="1" location="browser_use/browser/session.py:3026">
P3: This adds a duplicate JavaScript fallback. Move the single `getBoundingClientRect` fallback after quad validation so failed or zero-sized lookups do not double the CDP traffic.</violation>
</file>
<file name="skills/cloud/references/features.md">
<violation number="1" location="skills/cloud/references/features.md:195">
P2: This relative path still points to a nonexistent file: from `skills/cloud/references/features.md`, `../open-source/...` resolves under `skills/cloud`. Use `../../open-source/references/integrations.md` so readers can find the integration configuration.</violation>
</file>
<file name="skills/cloud/references/browser-api.md">
<violation number="1" location="skills/cloud/references/browser-api.md:120">
P2: This line tells free users they can run sessions for up to four hours, but the cloud request model still rejects free-user timeouts above 15 minutes. Keep the free-user limit here or update the runtime enforcement and related documentation together.</violation>
</file>
<file name="browser_use/config.py">
<violation number="1" location="browser_use/config.py:363">
P2: A migration write failure can truncate `config_path` before this backup runs, so `.bak` contains partial JSON instead of the original configuration. Create the backup before opening the original for writing, or write the migrated config to a temporary path and replace it atomically.</violation>
</file>
<file name="browser_use/actor/element.py">
<violation number="1" location="browser_use/actor/element.py:309">
P1: `press_attempted` does not indicate that the press failed; it is set before the press await. Consequently, a release-only timeout or CDP error is swallowed and `click()` reports success without a completed click. Track whether an earlier exception is active and re-raise release-only failures.</violation>
</file>
<file name="browser_use/tokens/service.py">
<violation number="1" location="browser_use/tokens/service.py:638">
P2: Negative `keep_count` values now delete every matching pricing cache. Restrict this special case to zero, or validate and reject negative values before the cleanup operation.</violation>
</file>
<file name="browser_use/llm/schema.py">
<violation number="1" location="browser_use/llm/schema.py:109">
P2: `default` never reaches this preservation branch because the preceding essential-fields branch still matches it, so dict/list defaults are recursively treated as schemas and can be changed. Remove `default` from that earlier list.</violation>
<violation number="2" location="browser_use/llm/schema.py:156">
P2: This guard still rewrites preserved example/const data that happens to contain `type: 'object'` and `properties`, adding schema-only fields to the value. Track schema-versus-data context and skip post-processing inside `default`, `examples`, and `const`.</violation>
<violation number="3" location="browser_use/llm/schema.py:203">
P2: `_make_strict_compatible` still traverses the `examples` and `const` payloads claimed to be preserved above, so it rewrites data that merely resembles a schema. Restrict the post-passes to schema nodes or explicitly skip `default`, `examples`, and `const` subtrees.</violation>
</file>
<file name="browser_use/tools/service.py">
<violation number="1" location="browser_use/tools/service.py:1128">
P2: This replacement is behaviorally identical to the previous code, so it does not fix the reported pagination error. `extract_clean_markdown()` already sets `content_stats['final_filtered_chars']` to `len(content)` and the value is read before `content` changes; fix the stale offset/length source and add a regression test for the newline case.</violation>
</file>
Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.
View guided diff | Re-trigger cubic
| try: | ||
| await asyncio.wait_for( | ||
| self._client.send.Input.dispatchMouseEvent( | ||
| params={ | ||
| 'type': 'mouseReleased', | ||
| 'x': center_x, | ||
| 'y': center_y, | ||
| 'button': button, | ||
| 'clickCount': click_count, | ||
| 'modifiers': modifier_value, | ||
| }, | ||
| session_id=self._session_id, | ||
| ), | ||
| timeout=3.0, # 3 second timeout for mouseReleased | ||
| ) | ||
| except Exception as release_exc: | ||
| # If the press already failed, keep the original error. | ||
| if press_attempted: | ||
| try: | ||
| import logging | ||
| logging.getLogger(__name__).debug( | ||
| "mouseReleased also failed after press failure: %s", release_exc | ||
| ) | ||
| except Exception: | ||
| pass | ||
| else: | ||
| raise |
There was a problem hiding this comment.
P1: press_attempted does not indicate that the press failed; it is set before the press await. Consequently, a release-only timeout or CDP error is swallowed and click() reports success without a completed click. Track whether an earlier exception is active and re-raise release-only failures.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At browser_use/actor/element.py, line 309:
<comment>`press_attempted` does not indicate that the press failed; it is set before the press await. Consequently, a release-only timeout or CDP error is swallowed and `click()` reports success without a completed click. Track whether an earlier exception is active and re-raise release-only failures.</comment>
<file context>
@@ -306,20 +306,33 @@ async def click(
- ),
- timeout=3.0, # 3 second timeout for mouseReleased
- )
+ try:
+ await asyncio.wait_for(
+ self._client.send.Input.dispatchMouseEvent(
</file context>
| try: | |
| await asyncio.wait_for( | |
| self._client.send.Input.dispatchMouseEvent( | |
| params={ | |
| 'type': 'mouseReleased', | |
| 'x': center_x, | |
| 'y': center_y, | |
| 'button': button, | |
| 'clickCount': click_count, | |
| 'modifiers': modifier_value, | |
| }, | |
| session_id=self._session_id, | |
| ), | |
| timeout=3.0, # 3 second timeout for mouseReleased | |
| ) | |
| except Exception as release_exc: | |
| # If the press already failed, keep the original error. | |
| if press_attempted: | |
| try: | |
| import logging | |
| logging.getLogger(__name__).debug( | |
| "mouseReleased also failed after press failure: %s", release_exc | |
| ) | |
| except Exception: | |
| pass | |
| else: | |
| raise | |
| import sys | |
| original_exception = sys.exc_info()[1] | |
| try: | |
| await asyncio.wait_for( | |
| self._client.send.Input.dispatchMouseEvent( | |
| params={ | |
| 'type': 'mouseReleased', | |
| 'x': center_x, | |
| 'y': center_y, | |
| 'button': button, | |
| 'clickCount': click_count, | |
| 'modifiers': modifier_value, | |
| }, | |
| session_id=self._session_id, | |
| ), | |
| timeout=3.0, # 3 second timeout for mouseReleased | |
| ) | |
| except Exception as release_exc: | |
| if original_exception is not None: | |
| try: | |
| import logging | |
| logging.getLogger(__name__).debug( | |
| "mouseReleased also failed after press failure: %s", release_exc | |
| ) | |
| except Exception: | |
| pass | |
| else: | |
| raise |
| | customProxy | object | no | `{ host, port, username?, password? }` (HTTP or SOCKS5) | | ||
|
|
||
| **Pricing:** $0.02/hour. Billed upfront, proportional refund on stop. Ceil to nearest minute (min 1 min). Free: 15 min max. Paid: 4 hours max. | ||
| **Pricing:** $0.02/hour. Billed upfront, proportional refund on stop. Ceil to nearest minute (min 1 min). All users: up to 4 hours (240 minutes) max. |
There was a problem hiding this comment.
P2: This now incorrectly tells free users that they can request up to 240 minutes, even though the cloud request model still limits them to 15 minutes and rejects longer timeouts. Preserve the free-tier limit in this pricing description.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At skills/cloud/references/api-v2.md, line 193:
<comment>This now incorrectly tells free users that they can request up to 240 minutes, even though the cloud request model still limits them to 15 minutes and rejects longer timeouts. Preserve the free-tier limit in this pricing description.</comment>
<file context>
@@ -190,7 +190,7 @@ Response: 204.
| customProxy | object | no | `{ host, port, username?, password? }` (HTTP or SOCKS5) |
-**Pricing:** $0.02/hour. Billed upfront, proportional refund on stop. Ceil to nearest minute (min 1 min). Free: 15 min max. Paid: 4 hours max.
+**Pricing:** $0.02/hour. Billed upfront, proportional refund on stop. Ceil to nearest minute (min 1 min). All users: up to 4 hours (240 minutes) max.
Response (201): BrowserSessionItemView (includes `cdpUrl` and `liveUrl`).
</file context>
| **Pricing:** $0.02/hour. Billed upfront, proportional refund on stop. Ceil to nearest minute (min 1 min). All users: up to 4 hours (240 minutes) max. | |
| **Pricing:** $0.02/hour. Billed upfront, proportional refund on stop. Ceil to nearest minute (min 1 min). Free: 15 min max. Paid: 4 hours max. |
| from browser_use.filesystem.file_system import Base64BinaryFile | ||
| if isinstance(file_obj, Base64BinaryFile): | ||
| result['message'] = f'Read image file {resolved}.' | ||
| result['images'] = [{'name': file_obj.full_name, 'data': file_obj.content}] |
There was a problem hiding this comment.
P2: This branch makes internal GIF and WebP files reach vision prompts, but the prompt formatter labels every non-PNG image as JPEG. Map .gif and .webp to their actual MIME types before sending these files to providers.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At browser_use/filesystem/file_system.py, line 862:
<comment>This branch makes internal GIF and WebP files reach vision prompts, but the prompt formatter labels every non-PNG image as JPEG. Map `.gif` and `.webp` to their actual MIME types before sending these files to providers.</comment>
<file context>
@@ -856,6 +856,11 @@ async def read_file_structured(self, full_filename: str, external_file: bool = F
+ from browser_use.filesystem.file_system import Base64BinaryFile
+ if isinstance(file_obj, Base64BinaryFile):
+ result['message'] = f'Read image file {resolved}.'
+ result['images'] = [{'name': file_obj.full_name, 'data': file_obj.content}]
+ return result
content = file_obj.read()
</file context>
| ) | ||
| elif response.status_code == 403: | ||
| raise CloudBrowserAuthError('Access forbidden. Please check your browser-use cloud subscription status.') | ||
| error_msg = 'Access forbidden.' |
There was a problem hiding this comment.
P2: The 403 fallback now drops the actionable subscription guidance whenever the response has no usable detail; preserve the previous fallback message and append the server detail when one is available.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At browser_use/browser/cloud/cloud.py, line 118:
<comment>The 403 fallback now drops the actionable subscription guidance whenever the response has no usable `detail`; preserve the previous fallback message and append the server detail when one is available.</comment>
<file context>
@@ -115,7 +115,14 @@ async def create_browser(
)
elif response.status_code == 403:
- raise CloudBrowserAuthError('Access forbidden. Please check your browser-use cloud subscription status.')
+ error_msg = 'Access forbidden.'
+ try:
+ error_data = response.json()
</file context>
| error_msg = 'Access forbidden.' | |
| error_msg = 'Access forbidden. Please check your browser-use cloud subscription status.' |
| from browser_use.filesystem.file_system import Base64BinaryFile | ||
| if isinstance(file_obj, Base64BinaryFile): | ||
| result['message'] = f'Read image file {resolved}.' | ||
| result['images'] = [{'name': file_obj.full_name, 'data': file_obj.content}] |
There was a problem hiding this comment.
P2: Internal images retain the write tool’s trailing newline in images[].data, producing a non-canonical base64 data URL that image providers may reject. Strip base64 whitespace when constructing the image payload.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At browser_use/filesystem/file_system.py, line 862:
<comment>Internal images retain the write tool’s trailing newline in `images[].data`, producing a non-canonical base64 data URL that image providers may reject. Strip base64 whitespace when constructing the image payload.</comment>
<file context>
@@ -856,6 +856,11 @@ async def read_file_structured(self, full_filename: str, external_file: bool = F
+ from browser_use.filesystem.file_system import Base64BinaryFile
+ if isinstance(file_obj, Base64BinaryFile):
+ result['message'] = f'Read image file {resolved}.'
+ result['images'] = [{'name': file_obj.full_name, 'data': file_obj.content}]
+ return result
content = file_obj.read()
</file context>
| result['images'] = [{'name': file_obj.full_name, 'data': file_obj.content}] | |
| result['images'] = [{'name': file_obj.full_name, 'data': ''.join(file_obj.content.split())}] |
| if not chunks: | ||
| return ActionResult( | ||
| error=f'start_from_char ({start_from_char}) exceeds content length {final_filtered_length} characters.' | ||
| error=f'start_from_char ({start_from_char}) exceeds content length {len(content)} characters.' |
There was a problem hiding this comment.
P2: This replacement is behaviorally identical to the previous code, so it does not fix the reported pagination error. extract_clean_markdown() already sets content_stats['final_filtered_chars'] to len(content) and the value is read before content changes; fix the stale offset/length source and add a regression test for the newline case.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At browser_use/tools/service.py, line 1128:
<comment>This replacement is behaviorally identical to the previous code, so it does not fix the reported pagination error. `extract_clean_markdown()` already sets `content_stats['final_filtered_chars']` to `len(content)` and the value is read before `content` changes; fix the stale offset/length source and add a regression test for the newline case.</comment>
<file context>
@@ -1125,7 +1125,7 @@ async def extract(
if not chunks:
return ActionResult(
- error=f'start_from_char ({start_from_char}) exceeds content length {final_filtered_length} characters.'
+ error=f'start_from_char ({start_from_char}) exceeds content length {len(content)} characters.'
)
chunk = chunks[0]
</file context>
| if isinstance(value, (dict, list)) and key != 'required': | ||
| # Note: we recurse into ALL dict/list values. The 'required' key holds a list of strings, | ||
| # and recursing into it is a no-op. This also correctly handles user fields named 'required'. | ||
| for value in schema.values(): |
There was a problem hiding this comment.
P2: _make_strict_compatible still traverses the examples and const payloads claimed to be preserved above, so it rewrites data that merely resembles a schema. Restrict the post-passes to schema nodes or explicitly skip default, examples, and const subtrees.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At browser_use/llm/schema.py, line 203:
<comment>`_make_strict_compatible` still traverses the `examples` and `const` payloads claimed to be preserved above, so it rewrites data that merely resembles a schema. Restrict the post-passes to schema nodes or explicitly skip `default`, `examples`, and `const` subtrees.</comment>
<file context>
@@ -193,13 +198,15 @@ def _make_strict_compatible(schema: dict[str, Any] | list[Any]) -> None:
- if isinstance(value, (dict, list)) and key != 'required':
+ # Note: we recurse into ALL dict/list values. The 'required' key holds a list of strings,
+ # and recursing into it is a no-op. This also correctly handles user fields named 'required'.
+ for value in schema.values():
+ if isinstance(value, (dict, list)):
SchemaOptimizer._make_strict_compatible(value)
</file context>
| AssistantMessage, | ||
| BaseMessage, | ||
| ContentPartImageParam, | ||
| ContentPartRefusalParam, |
There was a problem hiding this comment.
P3: ContentPartRefusalParam is imported but never referenced, so the enabled F401 check will fail and pre-commit will try to remove it. Delete this import.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At browser_use/llm/anthropic/serializer.py, line 18:
<comment>`ContentPartRefusalParam` is imported but never referenced, so the enabled F401 check will fail and pre-commit will try to remove it. Delete this import.</comment>
<file context>
@@ -15,6 +15,7 @@
AssistantMessage,
BaseMessage,
ContentPartImageParam,
+ ContentPartRefusalParam,
ContentPartTextParam,
SupportedImageMediaType,
</file context>
| try: | ||
| from browser_use.filesystem.file_system import Base64BinaryFile | ||
| if isinstance(file_obj, Base64BinaryFile): | ||
| result['message'] = f'Read image file {resolved}.' |
There was a problem hiding this comment.
P3: Preserve the auto-correction notice for internal images, matching the text-file path; otherwise reads such as [email protected] silently resolve to a different filename.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At browser_use/filesystem/file_system.py, line 861:
<comment>Preserve the auto-correction notice for internal images, matching the text-file path; otherwise reads such as `[email protected]` silently resolve to a different filename.</comment>
<file context>
@@ -856,6 +856,11 @@ async def read_file_structured(self, full_filename: str, external_file: bool = F
try:
+ from browser_use.filesystem.file_system import Base64BinaryFile
+ if isinstance(file_obj, Base64BinaryFile):
+ result['message'] = f'Read image file {resolved}.'
+ result['images'] = [{'name': file_obj.full_name, 'data': file_obj.content}]
+ return result
</file context>
| result['message'] = f'Read image file {resolved}.' | |
| result['message'] = (f"Note: filename was auto-corrected from '{full_filename}' to '{resolved}'. " if was_sanitized else '') + f'Read image file {resolved}.' |
| if width > 0 and height > 0: | ||
| return DOMRect(x=min_x, y=min_y, width=width, height=height) | ||
|
|
||
| # Fall back to JavaScript getBoundingClientRect |
There was a problem hiding this comment.
P3: This adds a duplicate JavaScript fallback. Move the single getBoundingClientRect fallback after quad validation so failed or zero-sized lookups do not double the CDP traffic.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At browser_use/browser/session.py, line 3026:
<comment>This adds a duplicate JavaScript fallback. Move the single `getBoundingClientRect` fallback after quad validation so failed or zero-sized lookups do not double the CDP traffic.</comment>
<file context>
@@ -2959,23 +2959,104 @@ async def get_element_coordinates(self, backend_node_id: int, cdp_session: CDPSe
+ if width > 0 and height > 0:
+ return DOMRect(x=min_x, y=min_y, width=width, height=height)
+
+ # Fall back to JavaScript getBoundingClientRect
+ try:
+ result = await cdp_session.cdp_client.send.DOM.resolveNode(
</file context>
Fixes #6003 - extract pagination was using final_filtered_length instead of len(content) in the error message, causing false positives when content ends in newline.
Summary by cubic
Fixes the extract pagination error to compare against the actual content length instead of the filtered length, eliminating false "start_from_char exceeds content length" errors when content ends in a newline. Also bundles several reliability and compatibility fixes across the browser automation stack.
Fixes
getBoxModelandgetBoundingClientRect.mouseReleasedalso fails.default/examples/constvalues and handles properties namedrequired.[Refusal]text blocks;gemini-3.5-flashis treated as Gemini 3 Flash.keep_count=0.Docs
Written for commit b99e8da. Summary will update on new commits.